ERROR 2002 (HY000): Can't connect to local MySQL

Building on the previous answers, all you should need to do is:

yum install mysql-server
service mysqld start

The first time the service is started, it should prompt you to set the root password.


Try typing:

service mysqld status

If it says anything other than that it is running try typing:

service mysqld start

Couple of clarifications:

  • /var/lib/mysql/mysql.sock is a file that is created by mysqld when it runs, it is what the client uses to connect to the server. If it isn't found then that means most likely the server isn't running
  • /usr/bin/mysql is the client executable. This is what connects to the mysql server. You should not point the socket in my.cnf to this file.

I agree with malonso that the server is probably not installed.