CentOS8系统MySQL8使用yum安装

禁用默认的MySQL

sudo yum module disable mysql

安装MySQL Yum Repository

sudo yum module disable mysql
wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm
sudo yum -y install mysql80-community-release-el8-1.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum repolist all | grep mysql

安装MySQL

sudo yum -y install mysql-community-server

启动MySQL

sudo service mysqld start

更改MySQL密码

查找系统初始化的密码:

sudo grep 'temporary password' /var/log/mysqld.log

显示类似如下:

2020-09-06T03:20:42.930214Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >uFwu)4+1D5a

登录MySQL:

mysql -uroot -p

使用刚刚的密码登录后,使用以下的语句重置密码(大小写、数字、特殊字符,最少8位):

ALTER USER 'root'@'localhost' IDENTIFIED BY '您的密码';

查看密码复杂度:

SHOW VARIABLES LIKE 'validate_password%';

开发环境可以调低密码复杂度:

set global validate_password.policy=LOW; 
set global validate_password.length=4;

允许root远程登录:

use mysql;
select host,user,plugin from mysql.user;
update user set host = '%' where user ='root';
flush privileges;

退出MySQL:

exit

开放端口

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload

未经允许不得转载:君子如兰 » CentOS8系统MySQL8使用yum安装

赞 (0)