您好,登錄后才能下訂單哦!
這篇文章主要介紹了在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
重啟數據庫
感謝你能夠認真閱讀完這篇文章,希望小編分享的“在Linux 6.3如何安裝mysql5.7.16數據庫”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。