yum安裝Mysql8 - Centos8

官方地址:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
參考博客地址:https://www.jianshu.com/p/0cdf95b3ef27

先執行 yum install 更新yum,若未安裝執行 yum install 進行安裝。


1:Download MySQL Yum Repository

wget http://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

2:Downloaded release package

yum install mysql80-community-release-el8-1.noarch.rpm

3:See all the subrepositories

yum repolist all | grep mysql

4:Installing MySQL

執行後報錯找不到...
yum install mysql-community-server

執行以下語句:
yum install mysql-server mysql-devel

查看版本:
mysqladmin --version

5:啓動mysql

systemctl start mysqld

6:開啓root遠程登錄

mysql -u root -p
進入後直接回車,並執行以下語句:

use mysql;
update user set host='%' where user ='root' ;
update user set authentication_string = "" where user = 'root' ;
flush privileges;
alter user 'root'@'%' identified with mysql_native_password by '${password}';
flush privileges;

7:修改時區爲東八區

查看當前數據庫時區:
show variables like '%time_zone%';

時區參照:

修改文件:/etc/my.cnf.d/mysql-server.cnf

重啓mysql
systemctl restart mysqld

若不更改時區,在JAVA8+MyBatis項目中使用LocalDateTime 類型作爲查詢條件時,會導致真正的查詢時間少8小時。

8:防火牆開啓3306提供外網訪問

添加3306端口:
firewall-cmd --permanent --zone=public --add-port=3306/tcp

重啓防火牆:
systemctl restart firewalld

若開啓了阿里雲/騰訊雲安全組則需要在安全組開放3306端口策略。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章