1. 配置連接端mysql設置
vim /etc/mysql/mysql.conf.d/mysql.cnf
#更改mysql.conf文件第43行綁定地址為mysql主機的外網地址.
43 bind-address = 192.168.0.1
2. 主機授權.
主機進入mysql. 輸入授權命令
grant all privileges on 授權的數據庫.數據庫中的具體表 to '連接端用戶'@'連接端IP地址' identified by '連接端輸入的密碼' with grant option;
例如:(授予IP-外網地址-為192.168.0.2下的root用戶使用密碼mypassword登錄時,對mydatabase數據庫下所有表格操作的權限.)
grant all privileges on mydatabase.* to 'root'@'192.168.0.2' identified by 'mypassword' with grant option;
激活授權
flush privileges;
完成.