一、安装软件
Navicat,SQLyog 这些软件都不错,不过都需要收费,当然也有破解版。下面用 MySQL Workbench,它是官方提供的工具。
![](https://img-blog.csdnimg.cn/direct/2e6d0c51d0304f7da5ebecedc4874a90.png)
![](https://img-blog.csdnimg.cn/direct/fdd3b60931d049e0a3feb9eec9459fd4.png)
![](https://img-blog.csdnimg.cn/direct/7a7654b2b5ac490bb7aecb164aee3e5f.png)
![](https://img-blog.csdnimg.cn/direct/bafca36877b140f5bd10eee0fa1b73b6.png)
![](https://img-blog.csdnimg.cn/direct/931a9667ab484d88a63bf33973d860f9.png)
二、使用操作
这个软件本质是一个客户端,现在要让数据库能够远程登录。不过一般不会远程登录,这样就暴露给其它主机了,要使用选定的端口号来连接才能保证自己数据库的安全。创建一个远程登录的数据库 Workbench。
![](https://img-blog.csdnimg.cn/direct/f7e6a8decab04ac6a0c61107f55dc511.png)
![](https://img-blog.csdnimg.cn/direct/2ca700a5164b4e8c938ff8497804ceee.png)
打开 MySQL Workbench:
![](https://img-blog.csdnimg.cn/direct/c3ea93d2e1fc462a951f999e6d69e907.png)
![](https://img-blog.csdnimg.cn/direct/f8c5f91ab3e049919767a25b972198d8.png)
最上面的 Connection Name 随便填,Hostname 要填自己云服务器的公网 IP,因为我的 mysql 在我的云服务器上,端口号用命令查看:netstat -nltp 或者登录 root 数据库,然后输入命令:show global variables like 'port';
![](https://img-blog.csdnimg.cn/direct/7e1d43d67e6b4bcd8bf6b4419a5f633c.png)
Username 填上面创建的库名,然后点击 Test Connection 并输入密码,填好后连接成功就会出现成功的消息。
![](https://img-blog.csdnimg.cn/direct/0aa0e4d92cd3453e9f5dec825891fc0c.png)
![](https://img-blog.csdnimg.cn/direct/6e6ad04b225e434cb9d51eae7723c72f.png)
打开后左边一栏 schemas,可以看到自己的库:
![](https://img-blog.csdnimg.cn/direct/968cc851f07e4536a1afb73582da180c.png)
![](https://img-blog.csdnimg.cn/direct/073267d96c134c449260c85aa615c3a4.png)
![](https://img-blog.csdnimg.cn/direct/f56deedff85b4ee3bf2d3a9c2c2ed130.png)
![](https://img-blog.csdnimg.cn/direct/cfb128f882e340f7b76ea680840e32b9.png)