centos安裝配置mysql5.7

1、mariadb和mysql

CentOS 7 已經放棄mysql安裝,而是安裝mariadb。(可能是版權問題)
所以,安裝centos 7安裝mysql不能直接用yum install mysql命令。
需用用如下的操作進行安裝。

2、下載mysql源安裝包

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

3.安裝mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm

4、安裝mysql

yum install mysql-community-server

5、啓動mysql服務

systemctl start mysqld

6.查看mysql的啓動狀態

systemctl status mysqld

7.設置開機啓動

systemctl enable mysqld
systemctl daemon-reload

8.修改密碼

需要先查看默認建立的密碼:
grep 'temporary password' /var/log/mysqld.log
結果可知:
A temporary password is generated for root@localhost: HrtC<+uh>2o1
mysql登錄:
mysql -u root -p
HrtC<+uh>2o1
修改密碼:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'HrtC<+uh>2o1';
mysql> set password for 'root'@'localhost'=password('自己的密碼');
注意:mysql5.7的密碼策略是:大小寫字母+符號
否則會報錯:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

9.查看密碼策略

mysql>show variables like ‘%password%’

10.添加允許遠程登錄用戶

grant all privileges on *.* to root@"%" identified by "自己的密碼";
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章