月光代碼園

記錄、分享、交流

导航

Centos7安装mysql8.0,开启远程访问

1.获取和安装官方yum源

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

sudo rpm -ivh mysql80-community-release-el7-3.noarch.rpm

执行成功后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo及 mysql-community-source.repo

yum repolist enabled | grep "mysql"

 

2.安装mysql

sudo yum install mysql-community-server

 

3.启动mysql服务

service mysqld start

查看当前mysql服务状态: systemctl status mysqld.service

 

4.开启远程访问mysql

4.1 开放防火墙端口访问

查看目前防火墙开放端口:firewall-cmd --list-ports

增加开放端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent

验证:firewall-cmd --list-ports

4.2 给予root用户远程访问权限

创建用户:create user 'root'@'%' identified by 'your password for root';

开启权限:grant all on *.* to 'root'@'%';

flush privileges

验证:telnet 192.168.1.107(远程ip) 3306

 至此本地客户端可以成功连接192.168.1.107:3306上的mysql

posted on 2019-08-05 19:49  bangdikka  阅读(3210)  评论(0编辑  收藏  举报