這篇文章主要介紹了在Linux 6.3如何安裝mysql5.7.16數(shù)據(jù)庫,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
為馬關(guān)等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及馬關(guān)網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、馬關(guān)網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!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組和用戶是否存在,如無創(chuàng)建。
[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]#
安裝過程中會(huì)生成my.cnf,手動(dòng)把原來的覆蓋
[root@QuDaoMysql _rpminstall]# cp /etc/my.cnf.rpmnew /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@QuDaoMysql _rpminstall]#
4、啟動(dòng)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 開始有默認(rèn)的密碼
[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、授權(quán)遠(yuǎn)程連接
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>
說明:如果遠(yuǎn)程連接不上,關(guān)閉防火墻。
8.配置mysql自動(dòng)啟動(dòng)
# chkconfig --level 345 mysqld on ---設(shè)置MySQL在345等級(jí)自動(dòng)啟動(dòng)
9.修改默認(rèn)目錄
關(guān)閉數(shù)據(jù)庫
[root@QuDaoMysql prlife]# service mysqld stop
Stopping mysqld: [ OK ]
[root@QuDaoMysql prlife]# cd /var/lib/
拷貝必須使用-a,否則權(quán)限會(huì)亂掉
[root@QuDaoMysql lib]# cp -a mysql /prlife/
修改第一個(gè)文件
修改/etc/my.cnf,修改前需要進(jìn)行備份
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/prlife/mysql/data
socket=/prlife/mysql/data/mysql.sock
再增加以下幾個(gè)參數(shù),否則會(huì)報(bào)錯(cuò)
[mysql.server]
user=mysql
basedir=/prlife/mysql/data/mysql
[client]
socket=/prlife/mysql/data/mysql.sock
修改第二個(gè)文件:mysqld
修改之前進(jìn)行備份
[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
修改第三個(gè)文件
修改之前先備份
cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak
vi /usr/bin/mysqld_safe
替換所有 /var/lib/mysql為 /prlife/mysql/data
(4)創(chuàng)建一個(gè)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
重啟數(shù)據(jù)庫
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“在Linux 6.3如何安裝mysql5.7.16數(shù)據(jù)庫”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!