wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022(如果rpm报错,执行此)
yum -y install mysql-community-server
启动:
systemctl start mysqld.service
systemctl status mysqld.service
grep "password" /var/log/mysqld.log(找默认密码)
mysql -uroot -p(登录)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';(改密码)
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;(开启远程访问,只允许192.168.0.1访问)
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;(开启远程访问,允许任意客户端访问)
flush privileges;
exit
firewall-cmd --zone=public --add-port=3306/tcp --permanent(防护墙开启3306)
firewall-cmd --zone=public --add-port=8080/tcp --permanent(防护墙开启8080)
firewall-cmd --reload
登录mysql,然后输入status
修改/etc/my.cnf,增加4行
[client]
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
重启mysql:
service mysqld restart
systemctl enable mysqld(开机自启动)
systemctl daemon-reload(开机自启动)
注意:云服务器安装远程访问时,打开云服务的安全组中,入方向的3306端口