阿里云服务 CentOS8.2 安装 MySQL5.7 (亲测稳定)

1、检查Centos版本

cat /etc/redhat-release

2、检查是否安装过MySQL

systemctl status mysqld.service

出现Unit mysqld.service could not be found. 表示没有安装

3、下载MySQL官方的Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

4、安装Yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

在这里插入图片描述
5、安装mysql

yum -y install mysql-community-server

在这里插入图片描述
出现以上错误,All matches were filtered out by modular filtering for argument: mysql-community-server

Error: Unable to find a match: mysql-community-server

解决办法:先执行 yum module disable mysql,然后再执行yum -y install mysql-community-server

6、卸载Yum Repository
由于每次 yum 操作都会自动更新,需要把这个卸载掉

yum -y remove mysql57-community-release-el7-10.noarch

7、查看MySQL状态

systemctl status mysqld.service

在这里插入图片描述
8、启动myql

systemctl start mysqld.service

在这里插入图片描述
9、查看mysql 临时密码

grep "password" /var/log/mysqld.log

在这里插入图片描述
临时密码是:iIn>yP=iE1&q

mysql -uroot –p

Enter password:iIn>yP=iE1&q

登录成功后:密码必须包含大小写字母、数字和特殊字符,不然修改密码失败

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySQL%57';

在这里插入图片描述
10、开启MySQL远程访问
执行以下命令开启远程访问限制(注意:下面命令开启的是%代表所有用户,如要开启某一个IP,用IP代替%)

mysql> grant all privileges on *.* to 'root'@'%' identified by 'MySQL%57' with grant option;

11、执行刷新命令

mysql> flush privileges;

12、在防火墙中添加3306端口

firewall-cmd --zone=public --add-port=3306/tcp –permanent

刷新防火墙

firewall-cmd --reload  

阿里云服务器安全组开启3306端口
在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值