How To Fix “Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)” Error?

by
Share this Article: Facebook0Google+0Twitter10LinkedIn0Reddit0StumbleUpon1

I have successfully installed MySQL or MariaDB, after rebooting my system and running mysql -u root -p, I get the following error message:

[~]$ mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Can't connect to local MySQL server through socket

 This definitely might be because you haven’t start MySQL server or MariaDB server.

Open Terminal and the command below to check the status:

# service mysql status

If the command above returns an error, you have definitely not started the server after booting.

Now start MariaDB:

# systemctl start mariadb.service

OR

# systemctl start mysqld.service

 

Enable auto start at boot time:

# systemctl enable mariadb.service

OR

# systemctl enable mysqld.service

 

If after all these and you still can’t access MariaDB, it means your installation wasn’t completed successfully:

Follow our article on How to Install LAMP Server (Apache, MariaDB And PHP) On Fedora 20/19

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter10LinkedIn0Reddit0StumbleUpon0