Overall, I’m trying to connect to a remote database server from another server.
One of my servers has LAMP installed. It can connect and send data to its local MySQL database and works fine.
The other server has only Linux and MySQL (LM) installed, in order to make a dedicated database server, and is setup using the following articles.
It has a database to use, if I could only connect to it.
Within the LM/database server’s /etc/mysql/my.cnf , I’ve adjusted the bind-address from localhost to the IP address of this server.
I’ve set up a new username with …
CREATE USER 'newusername'@'111.222.333.444' IDENTIFIED BY 'password';
Show grants reveals …
GRANT USAGE ON *.* TO 'newusername'@'111.222.333.444' IDENTIFIED BY PASSWORD '*abc123...'
This new username and password are the credentials, I’d like to connect with instead of using root. Additionally, when installing MySQL, to secure the database I chose to disallow root login remotely.
At the CLI I can connect remotely with …
mysql -u newusername -h 111.222.333.444 -p
However, when using a browser to send data from an HTML page to the PHP application portion of my LAMP server, and it trying to remote connect to the LM/database server to insert the data; I get my coded error message of not being able to connect to the LM/database server.
$db_connect = @mysql_connect("111.222.333.444", "newusername", "password"); if (!$db_connect) exit("<p>Unable to connect to the database server at this time.</p>");
When I can get things to work, I’ll remove MySQL from the LAMP server, so that this server becomes only an application server.
Passwords and IP addresses are all written correctly. I’ve granted All Privileges on newusername in the guess that would do something. Any suggestions of what to do? Thanks for any assistance.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.