Centos7
1、查看是否安装mysql
yum search mysql
未看到:mysql-community-server.x86_64
2、下载mysql源
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
3、查看是否安装mysql源
yum repolist enabled | grep "mysql.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 165
mysql-tools-community/x86_64 MySQL Tools Community 115
mysql57-community/x86_64 MySQL 5.7 Community Server 444
yum search mysql
...
mysql-community-server.x86_64 : A very fast and reliable SQL database server
...
安装源
yum localinstall mysql57-community-release-el7-10.noarch.rpm
4、安装mysql
yum install mysql-community-server
5、查看mysql版本
mysql -V
mysql Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using EditLine wrapper
6、启动和配置参考: Linux-mysql5.8安装过程
因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉:
yum -y remove mysql57-community-release-el7-10.noarch
设置权限
set password=password('123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
set global validate_password_policy=0;
set global validate_password_length=1;
set password=password('123456');
grant all on *.* to root@'%' identified by '123456';
flush privileges;
7、防火墙设置
systemctl status firewalld
systemctl start firewalld
systemctl status firewalld
防火墙需要开放 3306 端口,依次执行:
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=3306/udp
firewall-cmd --reload
如果是 CentOS 7,需要将 MySQL 服务加入防火墙,然后重启防火墙:
firewall-cmd --zone=public --permanent --add-service=mysql
firewall-cmd --reload #重载防火墙配置 或 systemctl restart firewalld 重启防火墙
8、本地远程连接到阿里云服务器,出现如下问题:
阿里云服务器设置,【防火墙】-【添加规则】
Centos8