安装 MySQL
sudo yum install mysql-community-server
修改 MySQL 配置文件
sudo vim /etc/my.cnf [mysqld] bind-address = 0.0.0.0 port = 3307
初始化 MySQL 数据目录
sudo mysqld --initialize --user=mysql
启动 MySQL 服务
sudo systemctl start mysqld
获取临时密码
sudo grep 'temporary password' /var/log/mysqld.log
修改 root 用户密码
mysql -u root -p
##修改 root 用户的密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123'; #
#设置远程连接权限
CREATE USER 'root'@'%' IDENTIFIED BY 'Root@123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
配置防火墙
# 启用防火墙
sudo systemctl start firewalld
sudo systemctl enable firewalld
# 开放1到10010端口范围
sudo firewall-cmd --zone=public --add-port=3007/tcp --permanent
# 重新加载防火墙以应用更改
sudo firewall-cmd --reload