Linux – ERROR 2002 (HY000): Can’t connect to local MySQL

linuxMySQL

Ok, I've got a fresh Fedora 12 install, and I have installed mysql via yum. I searched around, including a couple similar posts on this site, but haven't been able to find an answer to my issue specifically.

The first thing I tried to do was set the root password, but I recieved an error.

error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

then..

[root@FC ~]# mysqld

Command not found. Similar command is: 'mysql'

So, I do a whereis mysql.sock, thinking I can find the origin of the file and point my configuration file there.

[root@FC ~]# whereis mysql.sock
mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

Cool, just point socket in my.cnf to /usr/bin/mysql and that should work, right?

Wrong, for some reason it didn't even update the path in the error? Still shows 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'. Can anyone point me in the right direction?

Best Answer

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.