It's likely that the mysql server is bound to the loopback address, either 127.0.0.1 or the ipv6 equivalent, and so you would have to open that up to the LAN network. You can check that with the following command on the mysql server;
# netstat -lntp | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 20080/mysqld
That option for binding to an ip is configured in my.cnf
, or where ever the mysql config file is on your system, and can be changed to bind to all ips;
[mysqld]
bind-address = 127.0.0.1
change to
[mysqld]
bind-address = 0.0.0.0
and restart the mysql server. Obviously it's important to ensure permissions have been set correctly on the mysql server.
Where the config file lives depends on which version of mysql you are using, I see it at;
/etc/mysql/mysql.conf.d/mysqld.cnf
on Ubuntu 16.04.3 running mysql-server-core-5.7 but it's at /etc/my.cnf
on another CentOS box... so you might have to be more specific about that environment you are in...
You can test whether it's working by connecting to the private ip of the db server from the app server with the mysql-client
# echo "show databases;" | mysql -uroot -psomepass -h localhost
Database
information_schema
wp_is_annoying_db
mysql
performance_schema
sys
if that's not working you should start with the basics
ping the db server private ip address;
$ ping 192.168.x.x
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.051 ms
use telnet or netcat to test the port
$ telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
or use netcat, if telnet is not installed;
nc -v localhost 3306
Connection to localhost 3306 port [tcp/mysql] succeeded!