0. 概要
现在需要使用自己计算机上的 Mysql Wordbench
客户端来连接云服务器上的 Mysql
数据库。
1. 记录过程
[root@VM_0_7_centos ~]
CentOS Linux release 7.3.1611 (Core)
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;
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 , 需要解绑
vim /etc/mysql/mysql.conf.d/mysqld.cnf
找到bind-address
并在前面加上 #
注释该行
#bind-address = 127.0.0.1
运行 /etc/init.d/mysql restart
[email protected]:~$ /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:
. ok
- 再看3306端口状态
netstat -an | grep 3306
ubuntu@VM-15-131-ubuntu:~$ netstat -an | grep 3306
tcp6 0 0 :::3306 :::* LISTEN
3. 使用 Mysql Workbench
测试连接
