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

Export and import of MySQL databases from cPanel

For management on databases in your hosting account you can use the web application phpMyAdmin....

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 Manage a MySQL Database with phpMyAdmin in cPanel

How to Manage a MySQL Database with phpMyAdmin in cPanel? In order to manage a MySQL database...

How to remove a user from a MySQL database in cPanel

How to remove a user from a MySQL database in cPanel? You need to log in to the cPanel while...

How to see the MySQL variables

Log into your MySQL database and type: show variables; You will see the following: mysql>...