100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 腾讯云开放mysql端口_腾讯云服务器Mysql开启3306端口远程访问

腾讯云开放mysql端口_腾讯云服务器Mysql开启3306端口远程访问

时间:2019-04-07 20:08:23

相关推荐

腾讯云开放mysql端口_腾讯云服务器Mysql开启3306端口远程访问

0. 概要现在需要使用自己计算机上的 Mysql Wordbench 客户端来连接云服务器上的 Mysql 数据库。

1. 记录过程查看Centos版本

[root@VM_0_7_centos ~]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

查看当前 Ubuntu Server版本

ubuntu@VM-15-131-ubuntu:~$ sudo lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 16.04.1 LTS

Release: 16.04

Codename: xenial

修改user表里面的host项

登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称”%”

mysql -uroot -proot

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

查看3306端口是否状态

ubuntu@VM-15-131-ubuntu:~$ netstat -an | grep 3306

tcp6 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

可以发现: 3306端口绑定的IP地址是本地的127.0.0.1 , 需要解绑

修改Mysql配置文件

vim /etc/mysql/mysql.conf.d/f

找到bind-address 并在前面加上 # 注释该行

#bind-address = 127.0.0.1

重启Mysql让配置文件生效

运行 /etc/init.d/mysql restart

ubuntu@VM-15-131-ubuntu:~$ /etc/init.d/mysql restart

[....] Restarting mysql (via systemctl): mysql.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===

Authentication is required to restart 'mysql.service'.

Authenticating as: ubuntu,,, (ubuntu)

Password:

==== AUTHENTICATION COMPLETE ===

. ok

再看3306端口状态

netstat -an | grep 3306

ubuntu@VM-15-131-ubuntu:~$ netstat -an | grep 3306

tcp6 0 0 :::3306 :::* LISTEN

3. 使用 Mysql Workbench 测试连接

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。