Centos7安裝MySQL

1. 下載MySQL源安裝包

> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
複製代碼

2. 安裝MySQL源

> yum localinstall mysql57-community-release-el7-8.noarch.rpm
複製代碼

3. 檢查MySQL源是否安裝成功

> yum repolist enabled | grep "mysql.*-community.*"
複製代碼

4. 安裝MySQL

> yum install mysql-community-server
複製代碼

5. 啓動MySQL服務

> systemctl start mysqld
複製代碼

6. 設置MySQL開機啓動

> systemctl enable mysqld
> systemctl daemon-reload
複製代碼

7. 查看MySQLroot用戶的默認密碼

> grep 'temporary password' /var/log/mysqld.log
複製代碼

8. 鏈接MySQL,修改root用戶默認密碼

> mysql -uroot -p9L2dgbYNtZ.d
> alter user 'root'@'localhost' identified by '#{new password}'
複製代碼

必須包含:大小寫字母、數字和特殊符號,而且長度不能少於8位mysql

9. 添加遠程登錄用戶

> grant all privileges on *.* to 'root'@'%' identified by '#{new password}' with grant option;
複製代碼

10. 關閉防火牆(可選)

-- 查看防火牆狀況
> systemctl status firewalld.service

-- 關閉防火牆
> systemctl stop firewalld.service

-- 設置防火牆開機不啓動
> systemctl disable firewalld.service
複製代碼
相關文章
相關標籤/搜索