sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
sudo rpm -Uvh mysql80-community-release-el7-6.noarch.rpm
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community
官方解释:
(仅限 EL8 系统)基于 EL8 的系统(例如 RHEL8 和 Oracle Linux 8)包含默认启用的 MySQL 模块。除非禁用此模块,否则它会屏蔽 MySQL 存储库提供的包。要禁用包含的模块并使 MySQL 存储库包可见,请使用以下命令(对于启用 dnf 的系统, 将命令中的 yum替换为dnf)
sudo yum module disable mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo yum install mysql-community-server
vim /etc/my.cnf
这里更改存储目录和端口即可
port = 3306
datadir = /disk1/mysql
systemctl start mysqld
systemctl enablemysqld
[root@localhost]# sudo grep 'temporary password' /var/log/mysqld.log
2022-10-15T07:26:26.997188Z 1 [Note] A temporary password is generated for root@localhost: *********
利用8步骤的密码进入数据修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
首先设置root的host=%
use mysql; #进入数据库
update user set host = "%" where user = "root" ; #修改
FLUSH PRIVILEGES; #刷新配置
SELECT host,user FROM user ; #查看