(1)、檢查系統中是否默認安裝了mariadb,如果有,則一定要卸載,否則可能會與我們要安裝的mysql有沖突。
執行如下:systemctl stop mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
(2)、執行:yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm 下載8.0社區版
出現Complete表示完成。
(3)、安裝mysql-server : yum install mysql-community-server
出現以上內容表示安裝完成。
(4)、啟動mysql ,依次執行以下命令:
sudo systemctl enable mysqld
sudo systemctl start mysqld
sudo systemctl status mysqld
當出現:Active: active (running) since Mon 2019-9-9 09:54:07 CST; 5s ago 時,表示mysql服務啟動成功。
(5)、配置mysql password。第一次啟動mysql時系統會配置一個臨時密碼,可以用一下命令查詢:
grep 'temporary password' /var/log/mysqld.log
2019-9-9 T01:54:02.641021Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xnTQ2&pu*Vao2018-10-10T01:54:02.641021Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ptTT9&pu*hao
其中ptTT9&pu*hao就是我們新安裝的mysql的臨時密碼。
初始化密碼執行:
mysql_secure_installation
配置的密碼需要 大、小寫英文字母、數字、符號
(6)、配置遠程連接
mysql8和以前的版本在這一點不太一樣,mysql8安全級別\要求更高,所以在創建遠程連接用戶的時候,不能用原來的命令:
mysql>grant all PRIVILEGES on *.* to test@'localhost' identified by '123456';(不能使用,強行使用,系統會提示錯誤)
需要如下步驟:
1、先創建用戶:
mysql>create user admin@'%' identified by 'Fjp.123456789';
2、在對用戶賦予權限:
mysql>grant all privileges on *.* to admin@'%' with grant option;
3、最后執行,使我們的配置生效:
mysql>flush privileges;
(7)、應為mysql8.0默認的加密規則是:caching_sha2_password,我們必須使用同等級的遠程客戶端才能連接,否則會報:Unable to load authentication plugin 'caching_sha2_password 的錯誤
如果不想使用,可以修改用戶的加密規則為 mysql_native_password,命令如下:
mysql>alter user 'admin'@'%' IDENTIFIED with mysql_native_password by 'Fjp.123456789';
如此我們就可以對我們的mysql8進行遠程操作了。