centos yum安裝 mysql5.7 版本

來源:互聯網
上載者:User

標籤:upd   方案   重設root密碼   where   server   arch   create   local   具體步驟   

本人安裝的centos版本為7.2

參考文章:http://www.centoscn.com/mysql/2016/0626/7537.html

安裝過程並不複雜,具體步驟如下:

1. shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

2. shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

3. shell> yum install mysql-community-server //安裝mysql服務

4. shell> systemctl start mysqld //啟動mysql

5. 設定開機啟動

shell> systemctl enable mysqld

shell> systemctl daemon-reload

到這一步安裝已經完成了,並且啟動了mysql服務

6. 修改root預設密碼

mysql安裝完成之後,在/var/log/mysqld.log檔案中給root產生了一個預設密碼。

通過下面的方式找到root預設密碼,然後登入mysql進行修改:
shell> grep ‘temporary password‘ /var/log/mysqld.log
#####這裡會有一個臨時密碼,輸入以下命令,用臨時密碼登入
shell> mysql -uroot -p
然後輸入那個臨時密碼。

這裡說一下本人遇到的問題,當時安裝完成以後,使用臨時密碼卻無法登入,報
MySQL ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ 錯誤。
經過多方尋找,終於找到解決方案。 具體解決步驟如下:

shell>service mysqld stop
shell> vi my.cnf //我的my.cnf檔案在etc下面
然後在設定檔添加 skip-grant-tables
shell>service mysqld start
shell>mysql
mysql>use mysql

####接下來重設root密碼
mysql> update mysql.user set a uthentication_string=password(‘1q2w3E‘) where user=‘root‘ and Host =‘localhost‘;
mysql> flush privileges;
mysql> quit;
shell> vi my.cnf  

   在設定檔裡注釋掉 skip-grant-tables

shell>service mysqld stop
shell>service mysqld start

這裡再使用mysql -uroot -p 登入,輸入新的密碼即可登入

##建立資料庫
CREATE DATABASE gx_river;
###建立使用者並授予遠程登入許可權
GRANT ALL PRIVILEGES ON *.* TO ‘test‘@‘%‘ IDENTIFIED BY ‘test666‘ WITH GRANT OPTION;

 

 

 

centos yum安裝 mysql5.7 版本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.