centos7 下安裝MySQL

centos7 下安裝MySQL5.7

一:安裝

1:先安裝wget

yum -y install wget

2:從網址獲取

wget   https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

3:安裝MySQL源

yum -y localinstall mysql57-community-release-el7-11.noarch.rpm

4:在線安裝MySQL

yum -y install mysql-community-server

5)啓動MySQL服務

systemctl start mysqld

6)設置開啓啓動

systemctl enable mysqld

systemctl daemon-reload

一帆風順的安裝完成之後,登陸MySQL就悲催的發現報瞭如下錯誤:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

因此,大家可以直接進行以下操作,減少不必要的錯誤》~《

二:登陸MySQL

1:停止MySQL服務

systemctl stop mysqld.service

2:修改config文件,添加如下

進入config文件:

vim/etc/my.cnf

添加語句:

skip-grant-tables

3:開啓MySQL服務

systemctl start mysqld.service

4:進行無密碼登陸

mysql -u root

5:利用sql語句設置密碼

update mysql.user set authentication_string=password('設置的密碼') where user = 'root';

6:刷新服務器

flush priviledges

7:退出mysql

exit

8:停止服務

9:進入config文件,刪掉在底部添加的skip-grant-tables

10:開啓服務

11:登陸MySQL

mysql -u root -p



發佈了39 篇原創文章 · 獲贊 16 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章