1. 下载源
1 wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
2. 配置源
1 rpm -ivh mysql80-community-release-el7-3.noarch.rpm
3. 安装
1 yum install mysql-server -y
4. 安装时如果提示
则需要更新密钥
1 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
5. 启动、查看状态、设置开机启动
1 service mysqld start 2 service mysqld status 3 systemctl enable mysqld.service
6. 修改密码(默认也是没有密码的直接回车输入新密码)
1. 跳过验证 vi /etc/my.cnf 新增一行 skip-grant-tables 2. 重启 systemctl restart mysqld 3. 登录,提示输密码的话直接回车 mysql -uroot -p 4. 选择数据库 use mysql 5. 清空root密码 update user set authentication_string='' where user='root'; 刷新 flush privileges; 6. 退出 exit 7. 去掉第一步my.cnf中添加的skip-grant-tables 8. 重启 systemctl restart mysqld 9. 再次登录 mysql -u root -p 10.修改密码(复杂一点) ALTER USER 'root'@'localhost' IDENTIFIED BY 'H_3c*Ua'; 刷新 flush privileges; 11.退出 exit
7. 开启远程访问权限
1 mysql -u root -p 2 show databases; 3 use mysql; 4 show tables; 5 select user,authentication_string,host from user; 6 update user set host = '%' where user = 'root'; 7 flush privileges; 8 exit;
8. 开启防火墙端口
1. 开放3306端口 sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp 2. 重新加载防火墙规则使更改生效 sudo firewall-cmd --reload 3. 检查端口是否已开放 sudo firewall-cmd --list-ports
标签:MySQL8,root,--,mysqld,AnolisOS7.9,rpm,mysql,安装,user From: https://www.cnblogs.com/jf8710/p/18208528