在Linux 6.3安裝mysql5.7.16資料庫
1、下載安裝包
http://dev.mysql.com/downloads/
2.檢查庫檔案是否存在,如有刪除。
[root@QuDaoMysql mysql]# rpm -qa | grep mysql
mysql-5.1.61-4.el6.x86_64
qt-mysql-4.6.2-24.el6.x86_64
mysql-server-5.1.61-4.el6.x86_64
mysql-libs-5.1.61-4.el6.x86_64
mysql-devel-5.1.61-4.el6.x86_64
[root@QuDaoMysql mysql]#
[root@QuDaoMysql mysql]# rpm -e mysql-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e qt-mysql-4.6.2-24.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-server-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-devel-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]#
3.檢查mysql組和使用者是否存在,如無建立。
[root@QuDaoMysql mysql]# cat /etc/group | grep mysql
mysql:x:27:
[root@QuDaoMysql mysql]# cat /etc/passwd | grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
注意安裝順序
rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
########################################### [100%]
[root@QuDaoMysql _rpminstall]#
安裝過程中會生成my.cnf,手動把原來的覆蓋
[root@QuDaoMysql _rpminstall]# cp /etc/my.cnf.rpmnew /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@QuDaoMysql _rpminstall]#
4、啟動mysql
[root@QuDaoMysql _rpminstall]# /etc/rc.d/init.d/mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
[root@QuDaoMysql _rpminstall]#
5、mysql5.7 開始有預設的密碼
[root@QuDaoMysql _rpminstall]# cat /var/log/mysqld.log|grep 'temporary password'
2016-10-20T03:07:36.130787Z 1 [Note] A temporary password is generated for root@localhost: EGlLlD,dg2qe
[root@QuDaoMysql _rpminstall]#
初始密碼為 EGlLlD,dg2qe
6、登入
輸入密碼,重置密碼
[root@QuDaoMysql _rpminstall]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SET PASSWORD = PASSWORD('xxxxxx');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
mysql> SET PASSWORD = PASSWORD('xxxxxxx');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
7、授權遠端連線
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
說明:如果遠端連線不上,關閉防火牆。
8.配置mysql自動啟動
# chkconfig --level 345 mysqld on ---設定MySQL在345等級自動啟動
9.修改預設目錄
關閉資料庫
[root@QuDaoMysql prlife]# service mysqld stop
Stopping mysqld: [ OK ]
[root@QuDaoMysql prlife]# cd /var/lib/
拷貝必須使用-a,否則許可權會亂掉
[root@QuDaoMysql lib]# cp -a mysql /prlife/
修改第一個檔案
修改/etc/my.cnf,修改前需要進行備份
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/prlife/mysql/data
socket=/prlife/mysql/data/mysql.sock
再增加以下幾個引數,否則會報錯
[mysql.server]
user=mysql
basedir=/prlife/mysql/data/mysql
[client]
socket=/prlife/mysql/data/mysql.sock
修改第二個檔案:mysqld
修改之前進行備份
[root@QuDaoMysql mysql]# cp /etc/init.d/mysqld /etc/init.d/mysqld_bak
[root@QuDaoMysql mysql]# vi /etc/init.d/mysqld
替換所有 /var/lib/mysql為/prlife/mysql/data
修改第三個檔案
修改之前先備份
cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak
vi /usr/bin/mysqld_safe
替換所有 /var/lib/mysql為 /prlife/mysql/data
(4)建立一個mysql.sock的連結
[root@QuDaoMysql lib]# mkdir -p /var/lib/mysql/
[root@QuDaoMysql lib]# chown -R mysql.mysql /var/lib/mysql
[root@QuDaoMysql lib]# ln -s /prlife/mysql/data/mysql.sock /var/lib/mysql/mysql.sock
重啟資料庫
http://dev.mysql.com/downloads/
2.檢查庫檔案是否存在,如有刪除。
[root@QuDaoMysql mysql]# rpm -qa | grep mysql
mysql-5.1.61-4.el6.x86_64
qt-mysql-4.6.2-24.el6.x86_64
mysql-server-5.1.61-4.el6.x86_64
mysql-libs-5.1.61-4.el6.x86_64
mysql-devel-5.1.61-4.el6.x86_64
[root@QuDaoMysql mysql]#
[root@QuDaoMysql mysql]# rpm -e mysql-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e qt-mysql-4.6.2-24.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-server-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-devel-5.1.61-4.el6.x86_64 --nodeps
[root@QuDaoMysql mysql]#
3.檢查mysql組和使用者是否存在,如無建立。
[root@QuDaoMysql mysql]# cat /etc/group | grep mysql
mysql:x:27:
[root@QuDaoMysql mysql]# cat /etc/passwd | grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
注意安裝順序
rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
########################################### [100%]
[root@QuDaoMysql _rpminstall]#
安裝過程中會生成my.cnf,手動把原來的覆蓋
[root@QuDaoMysql _rpminstall]# cp /etc/my.cnf.rpmnew /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@QuDaoMysql _rpminstall]#
4、啟動mysql
[root@QuDaoMysql _rpminstall]# /etc/rc.d/init.d/mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
[root@QuDaoMysql _rpminstall]#
5、mysql5.7 開始有預設的密碼
[root@QuDaoMysql _rpminstall]# cat /var/log/mysqld.log|grep 'temporary password'
2016-10-20T03:07:36.130787Z 1 [Note] A temporary password is generated for root@localhost: EGlLlD,dg2qe
[root@QuDaoMysql _rpminstall]#
初始密碼為 EGlLlD,dg2qe
6、登入
輸入密碼,重置密碼
[root@QuDaoMysql _rpminstall]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.16
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SET PASSWORD = PASSWORD('xxxxxx');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
mysql> SET PASSWORD = PASSWORD('xxxxxxx');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
7、授權遠端連線
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
說明:如果遠端連線不上,關閉防火牆。
8.配置mysql自動啟動
# chkconfig --level 345 mysqld on ---設定MySQL在345等級自動啟動
9.修改預設目錄
關閉資料庫
[root@QuDaoMysql prlife]# service mysqld stop
Stopping mysqld: [ OK ]
[root@QuDaoMysql prlife]# cd /var/lib/
拷貝必須使用-a,否則許可權會亂掉
[root@QuDaoMysql lib]# cp -a mysql /prlife/
修改第一個檔案
修改/etc/my.cnf,修改前需要進行備份
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/prlife/mysql/data
socket=/prlife/mysql/data/mysql.sock
再增加以下幾個引數,否則會報錯
[mysql.server]
user=mysql
basedir=/prlife/mysql/data/mysql
[client]
socket=/prlife/mysql/data/mysql.sock
修改第二個檔案:mysqld
修改之前進行備份
[root@QuDaoMysql mysql]# cp /etc/init.d/mysqld /etc/init.d/mysqld_bak
[root@QuDaoMysql mysql]# vi /etc/init.d/mysqld
替換所有 /var/lib/mysql為/prlife/mysql/data
修改第三個檔案
修改之前先備份
cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak
vi /usr/bin/mysqld_safe
替換所有 /var/lib/mysql為 /prlife/mysql/data
(4)建立一個mysql.sock的連結
[root@QuDaoMysql lib]# mkdir -p /var/lib/mysql/
[root@QuDaoMysql lib]# chown -R mysql.mysql /var/lib/mysql
[root@QuDaoMysql lib]# ln -s /prlife/mysql/data/mysql.sock /var/lib/mysql/mysql.sock
重啟資料庫
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21605631/viewspace-2126831/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 講解Linux資料庫安裝Linux資料庫
- Linux下安裝Mysql資料庫LinuxMySql資料庫
- Linux安裝MariaDB資料庫-1Linux資料庫
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- Alibaba Cloud Linux 安裝 PostgreSQL 資料庫CloudLinuxSQL資料庫
- 在anlions os上安裝資料庫資料庫
- 在FreeBSD中安裝MySQL資料庫MySql資料庫
- 達夢資料庫DM8在LINUX環境下安裝步驟資料庫Linux
- db2 v9.7 linux 6.3安裝問題DB2Linux
- Linux系統徹底解除安裝MySQL資料庫LinuxMySql資料庫
- Linux環境下達夢資料庫安裝及解除安裝手冊Linux資料庫
- MongoDB資料庫安裝MongoDB資料庫
- Redis 資料庫安裝Redis資料庫
- oricle資料庫安裝資料庫
- GreenPlum資料庫安裝資料庫
- openGauss資料庫在CentOS上的安裝實踐資料庫CentOS
- 9、Linux下mysql資料庫安裝與配置實操LinuxMySql資料庫
- mysql在linux安裝MySqlLinux
- Oracle 資料庫打包安裝Oracle資料庫
- Ubuntu安裝MySQL資料庫UbuntuMySql資料庫
- tar方式安裝資料庫資料庫
- 達夢資料庫安裝資料庫
- 「Oracle」Oracle 資料庫安裝Oracle資料庫
- Hbase資料庫安裝部署資料庫
- Oracle Linux 7.1中安裝達夢資料庫DM7OracleLinux資料庫
- PostgreSQL 資料庫學習 - 0. 資料庫安裝SQL資料庫
- 達夢8資料庫安裝和解除安裝資料庫
- oracle rac資料庫的安裝Oracle資料庫
- vgant 安裝oracle資料庫racOracle資料庫
- 安裝MySQL8資料庫MySql資料庫
- sqlserver資料庫下載安裝SQLServer資料庫
- 1. PostgreSQL 資料庫安裝SQL資料庫
- 在linux中安裝DockerLinuxDocker
- 在Linux上安裝gskitLinux
- 在Linux下安裝JDKLinuxJDK
- 11. Oracle for Linux安裝和配置—11.3. Oracle安裝和配置—11.3.2. 資料庫建立OracleLinux資料庫
- 使用虛擬機器在CentOS上安裝部署資料庫使用虛擬機CentOS資料庫
- 【PG資料庫】PG資料庫的安裝及連線方法資料庫
- 【Linux】mysql下載與安裝與重置密碼與建立資料庫LinuxMySql密碼資料庫