CentOS8安装MySQL8(yum源安装)
官方下载地址:https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
参考博客地址:https://www.jianshu.com/p/0cdf95b3ef27
各个版本rpm包地址:https://yum.oracle.com/repo/OracleLinux/OL7/MySQL57_community/x86_64/
先执行 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%';
②:时区参照
③:修改文件
vim /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端口策略。