Can’t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

If you receive this error message when connecting to MySQL trough command line on your VPS hosting or dedicated server:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Then you have to use the following for access to MySQL -h 127.0.0.1:

mysql -h 127.0.0.1 -u dbuser -p database

If you receive this error message from web script, please check the status of the MySQL server.

  • 55 Users Found This Useful
Was this answer helpful?

Related Articles

How to assign a user to a MySQL database in cPanel

How to assign a user to a MySQL database in cPanel? First you need to log in to the cPanel...

How to setup a database using the MySQL Database Wizard in cPanel

How to setup a database using the MySQL Database Wizard in cPanel? Login to your cPanel...

Export and import MySQL databases via SSH

If you want to import your MySQL database through SSH on your VPS or dedicated server, use the...

How to repair a MySQL database in cPanel

How to repair a MySQL database in cPanel? In order to repair a MySQL database in cPanel, you...

How to delete a MySQL database user in cPanel

How to delete a MySQL database user in cPanel? Once you log in to the cPanel while using your...