centos 安装 mysql

一.下载并安装

1.下载MySQL官方的Yum Repository

wget -i -c http://dev.mysql.com/get/mysql58-community-release-el8-2.noarch.rpm

2.安装Yum Repository

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

3.安装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

4.卸载Yum Repository

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

yum -y remove mysql58-community-release-el8-2.noarch

二.启动MYSQL|修改密码|开启远程访问

1.启动MYSQL

systemctl start mysqld.service

2.日志查看初始密码

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

3.登陆

mysql -uroot -p

4.开启远程访问

CREATE USER 'root'@'%' IDENTIFIED BY '你的密码'; (密码最好是包含大写,小写,特殊字符,否则可能设置失败)
GRANT ALL ON *.* TO 'root'@'%'; 
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

5.防火墙添加端口3306

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

重新加载 firewall-cmd --reload

若防火墙未开启,需要先启动防火墙 systemctl start firewalld

查看防火墙端口 firewall-cmd --list-ports

6.需要在控制台添加安全组,开放3306端口

例如腾讯云:

7.测试

 success;

参考:

阿里云服务器CentOS8.2安装MySQL5.7_多学习,多总结-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值