![]() |
How to fix ERROR 2002 (HY000): Can't connect to local MySQL server through socket
I always forget to change this setting when attempting to copy/paste somebody else's MySQL config file (my.cnf). :o
Always locate your original socket setting before overwriting your existing my.cnf -- or if you're smart, before creating a new my.cnf after renaming the old one. I like to mv the old one to my.cnf.default, just in case. For example, this is the proper socket for my dev server: Code:
socket = /var/run/mysqld/mysqld.sockCode:
[mysqld]Code:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)socket = /var/lib/mysql/mysql.sock socket = /var/run/mysqld/mysqld.sock Wrong location = MySQL will not start. Oops. --- Don't feel too stupid. I had to Google it, too. :P This post, like many others, is a note to self. So much time passes between setting up servers (weeks to months), that I tend to forget some of the easy tasks. In the old days, we kept notebooks. Those were not as easy to search and forums and blogs, however, especially if you power your searches with Google's engine! If you've come across this post, I hope it's helped you. And welcome to the site. :) __________________ Need a good host? .Find one here: List of the Best Web Hosts in 2012 - Shared, reseller and VPS hosting |
This can also happen on a new MySQL installation, where:
Simply CTRL-C out of the mysql_secure_installation, and start MySQL: Code:
service mysqld start |
Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.