Report this

What is the reason for this report?

Problem on remote MySQL DB server connection

Posted on April 5, 2017

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 ?



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!

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.

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.

@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.

@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;

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.