What is this error?
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Not a developer? Go to MovableType.com
What is this error?
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Charlie Gorichanaz on October 16, 2013, 2:48 p.m. Reply
Hi Nathan,
This error can have a number of causes.
This installation never worked
If you are setting up a new Movable Type installation or configuring MT on a new server, the most likely cause is incorrect database settings in your
mt-config.cgi
file. The correct settings depend on your hosting environment.If your hosting provider does not allow console access to the server hosting the MySQL database, you will need to contact your host to verify the database details. If they do allow console access, you can verify the settings on a command line.
For example, your
mt-config.cgi
might contain these lines:Then you could connect to your database from a computer with a MySQL client installed by opening a terminal window and entering the command:
You would then be prompted for your password, and if successful, you will end up with a prompt like
mysql>
. Then you can typeexit;
to close it.If that does not work, you might get another error message that would help diagnose further.
This installation used to work
If the
DBHost
is set tolocalhost
or127.0.0.1
, you are telling MT to connect to a MySQL server hosted on the same server. The error you reported could be caused by MySQL not running.You can check if MySQL is running by entering commands like:
Debian or Ubuntu Linux:
RedHat or Fedora:
If you get the same socket error, you can try stating MySQL by running the same commands but replacing “status” with “start”. If successful, try loading MT again.
Still having problems?
Possibly MySQL could have been reconfigured, or you have multiple copies of MySQL installed, or something else. The socket file might need to be pointed to a new location. This can get complicated and would require more troubleshooting, but you can find some ideas on the StackOverflow question “Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)”.