Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

October 21, 2015 1.6k views
MySQL

Hello,

I have two droplets, one with a database and one with a website.
I have installed LAMP in both of them (except for the droplet that contains the website which does not have MySQL installed).

I tested the droplets with a simple index page which makes a simple connection to the database and brings text from it to be printed in the body and YES IT DOES WORK, so this confirms me that MySQL server is up and running.

However, when I upload a bigger website I get an error message that says:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

(Note that this bigger website works perfectly in localhost, running XAMPP)

First tip given was to change the droplet containing the database to one with more capacity, and I did that, however the problem persists.

Then I was told to change the bind address to 0.0.0.0 in "/etc/mysql/my.cnf"… I also did this and still nothing…

Any suggestion??

Thank’s in advanced

1 comment
  • It sounds like your app is attempting to connect to a MySQL service on the same server using /var/run/mysqld/mysqld.sock rather than attempting to connect via the service's IP address and port. I would check your app's configuration and ensure it is set up properly for your remote db server.

1 Answer

This question was answered by @ryanpq:

It sounds like your app is attempting to connect to a MySQL service on the same server using /var/run/mysqld/mysqld.sock rather than attempting to connect via the service's IP address and port. I would check your app's configuration and ensure it is set up properly for your remote db server.

View the original comment

Have another answer? Share your knowledge.