Centos7安装Mysql5.7.30

Centos7安装Mysql5.7.30

  • 1.下载,上传,解压,安装(一条命令)
  • 2.启动,改密码,修改登录规则
  • 3测试连接

1.下载,上传,解压,安装(一条命令)

下载地址 https://downloads.mysql.com/archives/community/
Centos7安装Mysql5.7.30_第1张图片

上传Centos7安装Mysql5.7.30_第2张图片

解压
$ tar xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
Centos7安装Mysql5.7.30_第3张图片

安装(一条命令)Centos7安装Mysql5.7.30_第4张图片

## 安装(这是一条命令)
$ rpm -e --nodeps mariadb-libs && \
	yum localinstall -y mysql-community-common-5.7.30-1.el7.x86_64.rpm && \
	yum localinstall -y mysql-community-libs-5.7.30-1.el7.x86_64.rpm && \
	yum localinstall -y mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm && \
	yum localinstall -y mysql-community-devel-5.7.30-1.el7.x86_64.rpm && \
	yum localinstall -y mysql-community-client-5.7.30-1.el7.x86_64.rpm && \
	yum localinstall -y mysql-community-server-5.7.30-1.el7.x86_64.rpm

2.启动,改密码,修改登录规则

如图,启动服务,查看初始密码
Centos7安装Mysql5.7.30_第5张图片

## 启动服务,查看初始密码
$ systemctl start mysqld && \
	systemctl enable mysqld && \
	cat /var/log/mysqld.log | grep password

登录
$ mysql -uroot -p’???’

修改密码,修改登陆规则,刷新
Centos7安装Mysql5.7.30_第6张图片
mysql> $ set global validate_password_length=4;
mysql> $ set global validate_password_policy=0;
mysql> $ set password=password(‘1234qwer’);
mysql> $ use mysql;
mysql> $ update user set host=’%’ where host=‘localhost’;
mysql> $ delete from user where host !=’%’;
mysql> $ flush privileges;
mysql> $ quit;

3测试连接

虚拟机需要关闭防火墙(我这里用的是虚拟机), 阿里云需要开启入栈规则

## 关闭防火墙
$ sudo systemctl stop firewalld && \
	sudo systemctl disable firewalld && \
	iptables -F  && \
	firewall-cmd --state

账号 root
密码 1234qwer
主机 192.168.136.130
Centos7安装Mysql5.7.30_第7张图片
Centos7安装Mysql5.7.30_第8张图片

你可能感兴趣的:(运维)