Re: Cannot connect to remote mysql.
Hi Tom,
Roel here. Thanks for the comment on
https://www.percona.com/blog/2015/03/17/free-mysql-qa-and-bash-linux-training-series/ :)
I have to read into your question a bit to understand what is happening. Reading into what someone related may lead to errors, so tell me if something sounds off.
You say that localhost works. So I assume that either you are working on a server that has MySQL installed, or some home PC/your workstation.
I am also working on the basis that we want to take these steps in connecting;
1) localhost (works)
2) same host, but using the external IP
3) different host, using the external IP of the host used in 1 and 2.
If localhost works, but not the external IP of the same machine (i.e. if you have MySQL on a server and localhost connection works then the next test is to use the external IP address of that server from the same machine) then somehow there is a firewall/blocker in between which filters/denies that traffic.
IP rules can indeed be restricted to certain IP addresses (or blocks of addresses). You will have to be more detailed in your setup, including IP's (you can obfuscate them if you like) and firewalls etc. if you want to dig deeper together.
The next thing to do is to also check that your MySQL privileges are in place. You'll have to give an overview of the GRANT's you setup. And, what is the exact failure when you connect etc.
PS. Instead of a PHP script, you can simply use the mysql client binary that comes with every MySQL distribution in the bin directory. Use -h / -u / -P etc. options. This may also produce clearer error messages to look at.
God bless,
Roel