- 在主机内执行 如下命令,确保mysql已开启
netstat -tap | grep mysql
- 检查主机安全组设置,确保3306端口可以访问
- 主机的mysql内执行如下语句(mysql默认是绑定在localhost的,需要更换为 ‘%’ 也就是所有ip)
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
- 修改 /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0