Question

Problem on remote MySQL DB server connection

Hi Digital Oceans, I’ve two ubuntu 16.04 server configured with this tutorial. The first one (Called A) is the MySQL DB server and the second one (Called B) is the Laravel based server. I wanna use server A as DB of server B, So in the server B, I’ve changed the bind-address to 0.0.0.0 and created same DB users on both servers, but when I tried to connect server A with this code:

mysql -h <server-A-IP> -u <user>

I got this error:

ERROR 2003 (HY000): Can't connect to MySQL server on '185.129.169.33' (111)

Could you help me ?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@jtittle, @vijaykumarmaurya

Finally, I just found the result. On the database server, I create two users:

CREATE USER  'dbuser'@'localhost' identified by 'dbpass' ;

and

CREATE USER  'dbuser'@'%' identified by 'dbpass' ;

and then grants all privileges:

 GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost' WITH GRANT OPTION;

and

GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'%' WITH GRANT OPTION;

@javadroid

On the database server, when you create a MySQL User and Database, you need to set the host for the user to that of the connecting server (i.e. the server you’re running your Laravel app on).

For example, on the database sever, to create a user, we’d use:

grant all on dbname.* to 'dbuser'@'LARAVEL_SERVER_IP' identified by 'dbpass';

Where dbname is the database name, dbuser is the database username, dbpass is the database password, and LARAVEL_SERVER_IP is the IP of your server running the Laravel application.

Just comment the bind address on my.cnf file and restart the mysql service.

One thing you can also check to bind your server IP address in my.cnf file and restart mysql services.

Please let me know in it help you.