通過Yum安裝
- 在官網(wǎng)找到對應(yīng)的rpm
<pre>http://dev.mysql.com/downloads/repo/yum/</pre> - 點擊download進(jìn)入下載
<pre>http://dev.mysql.com/downloads/file/?id=459921</pre> - 在頁面底部有個名為《 No thanks, just start my download.》的鏈接游两,這個鏈接就是下載地址。
<pre>http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm</pre> - 在服務(wù)器上安裝rpm
<pre>rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm</pre> - 更新yum
<pre>yum update</pre> - 安裝mysql
<pre>yum install -y mysql-community-server</pre> - 開啟mysql服務(wù)
<pre>systemctl start mysqld.service</pre> - 獲取mysql默認(rèn)密碼
<pre>grep 'temporary password' /var/log/mysqld.log</pre>
2015-11-30T03:16:23.337689Z 1 [Note] A temporary password is generated for root@localhost: ylW?D-q+l6Ip
命令運行后得到上面一句字符串,其中ylW?D-q+l6Ip
就是密碼
- mysql安全配置
<pre>mysql_secure_installation</pre>
- Enter password for user root:
輸入剛剛得到的密碼 - New password:
輸入新的密碼 - Re-enter new password:
重復(fù)輸入新的密碼 - Change the password for root ? ((Press y|Y for Yes, any other key for No)
是否想改變root的密碼虹统,輸入Y荞驴,重復(fù)設(shè)置密碼侵浸。 - Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No)
輸入Y - Remove anonymous users? (Press y|Y for Yes, any other key for No)
刪除匿名用戶戴卜,輸入Y - Disallow root login remotely? (Press y|Y for Yes, any other key for No)
是否禁止遠(yuǎn)程登錄刹碾,輸入N故觅,(但事后發(fā)現(xiàn)還是不能遠(yuǎn)程登錄厂庇,可以試試Y) - Remove test database and access to it? (Press y|Y for Yes, any other key for No)
是否刪除test數(shù)據(jù)庫,輸入N - Reload privilege tables now? (Press y|Y for Yes, any other key for No)
是否重新加載權(quán)限表输吏,輸入Y
- 安裝完成
可以通過mysql -uroot -p
登錄权旷,密碼是剛剛設(shè)置的