CentOS 6.5/6.6 安裝mysql 5.7

月夜原野發表於2017-10-16

Step1: 檢測系統是否自帶安裝mysql

de  ># yum list installed | grep mysql
de>

Step2: 刪除系統自帶的mysql及其依賴
命令:

de  ># yum -y remove mysql-libs.x86_64
de>
de  >注:用de> yum -y remove xxx【xxx是你第一步驟命令的輸出】,這個步驟不能省略,不然下面會出現一堆莫名其妙的問題;

Step3: 給CentOS新增rpm源,並且選擇較新的源
命令:

de  ># wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# yum localinstall mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
# yum-config-manager --disable mysql55-community
# yum-config-manager --disable mysql56-community
# yum-config-manager --enable mysql57-community-dmr
# yum repolist enabled | grep mysql
de>
de  >注:如果de>yum-config-manager這個命令沒有,直接yum yum-*即可

Step4:安裝mysql 伺服器
命令:

de  ># yum install mysql-community-server
de>

Step5: 啟動mysql
命令:

de  ># service mysqld start
de>

Step6: 檢視mysql是否自啟動,並且設定開啟自啟動
命令:

de  ># chkconfig --list | grep mysqld
# chkconfig mysqld on
de>

Step7: 獲取mysql初始密碼:

#######從mysql程式日誌中獲取root使用者的初始密碼:ra%yk7urCBIh
de style="box-sizing: border-box; padding: 0px; border-radius: 0px; overflow-wrap: normal; background-image: none; background-attachment: initial; background-color: initial; background-size: initial; background-origin: initial; background-clip: initial; background-; background-repeat: initial;"  >
[root@typecodes ~]# grep "password" /var/log/mysqld.log
2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password'
2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password'
2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'


Step8: mysql安全設定
命令:# mysql_secure_installation

step9:登陸mysql,建立使用者,資料庫等

參照:http://cyxinda.blog.163.com/blog/static/36596186201503162841301/

step10:

MySQL的配置檔案依然是de style="box-sizing: border-box; font-size: 12px; padding: 2px 4px; color: rgb(199, 37, 78); white-space: nowrap; border-radius: 2px; overflow: auto; background-color: rgb(249, 242, 244);" >/etc/my.cnfde>,其它安裝資訊可以通過de style="box-sizing: border-box; font-size: 12px; padding: 2px 4px; color: rgb(199, 37, 78); white-space: nowrap; border-radius: 2px; overflow: auto; background-color: rgb(249, 242, 244);" >mysql_configde>命令檢視。其中,動態庫檔案存放在de style="box-sizing: border-box; font-size: 12px; padding: 2px 4px; color: rgb(199, 37, 78); white-space: nowrap; border-radius: 2px; overflow: auto; background-color: rgb(249, 242, 244);" >/usr/lib64/mysqlde>目錄下。

調優mysql引數:http://cyxinda.blog.163.com/blog/static/365961862016066020391/

[root@master2 ~]# mysql_config

 

相關文章