I’m getting error when I run mysql -u root -p

Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

How do I solve this problem under CentOS / RHEL / Red Hat Enterprise Linux server 5.x or 6.x?

Is MySQL Running?

Type the following command

If mysqld is not running, start it:

Try mysql command again as follows:

Is MySQL Installed?

Make sure the package mysql-server is installed:

Sample outputs:

If you do not see package name, type the following command to install mysql-server:

Turn on mysqld to start automatically on boot:

Run mysqld service, enter:

Set a new root password for mysql server:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.