Why do I get error message: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' on shell?

If you get this error message when trying to use mysql command line utility from shell:

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

It means you need to access the mysql using -h 127.0.0.1 e.g.

mysql -h 127.0.0.1 -u yourdbuser -p yourdatabase

If you get this error message from a web script, please check with support for the status of the mysql server.

Was this answer helpful?

 Print this Article

Also Read

What is MySQL?

MySQL is an open source relational database management system. MySQL is noted mainly for its...

MySQL Database Wizard

cPanel can guide you through the process of setting up a MySQL database, along with the...

Can I connect remotely to MySQL database?

Yes! it is possible. For this you have to allow remote access from your control panel, by adding...

How to create and use MySQL database

MySQL Databases Databases offer a method for managing large amounts of information easily...

How do I connect to and use MySQL?

Please login to your control panel and follow these steps to create the database, user and its...