1.edited /etc/mysql/mysql.conf.d/mysqld.cnf on the database server and changed the bind-address to be the private IP of the database server.
将内网ip写入mysql 的配置文件 mysqld.cnf
2.In addition to allowing remote connections through the firewall and network interface, you will also need to add a MySQL user that is allowed to authenticate remotely. By default, most users should be allowed to connect only from
To do that, run
mysql -u root -p and enter your MySQL root password and run the following command to add the user:
GRANT ALL ON database_name.* TO email@example.com IDENTIFIED BY 'your_password';将数据库的访问权，授权给内网ip
Make sure you replace the red parts with the relevant details, with
xx.xx.xx.xx being the private IP of the web server. The username doesn’t have to be unique, as long as the host and username combination is unique.
Once you’ve done that, run
while still in the MySQL prompt in order to have it reload the privileges/credentials table and you should then be able to connect to the database from your web server.
definitely firewall problem. temporarily disable firewall or run only the following command to test
sudo ufw allow 3306（未完待续）（仅仅是记录资料）