I recently moved my /home folder to its own partition, but in doing so, I broke MySQL. The full error I got was:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
To fix this you need to create the file and make sure that MySQL has access to it. (All commands need to be run as root)
Create the directory (if it doesn’t already exist).
sudo mkdir /var/run/mysqld/
Create the file by “touching” it.
sudo touch /var/run/mysqld/mysqld.sock
Set the ownership of the mysqld.sock file and folder to mysql.
sudo chown -R mysql /var/run/mysqld/
You can then start MySQL and breath easier.
i’ve followed your instruction, then it came out like this
root@razman-laptop:~# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111)
I had the same problem and got the same error as razman after this ‘fix’
I have same problem…
Same answers again and again.
Again another unsolved problem. Noone seems to investigate what the heck is going on.
It seems the OS have to be reinstalled.
Ubuntu for Human DOING!
This is the problem with free stuff… You have to self service yourself waisting 3 – 4 days reading and posting to figure out why a file might just disapear alone. This thing just happened to me and that’s why i ended here.
Cheers everybody, may the Varchaaar be with u all !
The provided solution works when I logged in as root but when I logged in as another user I face the same error. Dont know what the problem is..
i killed the mysqld process, and restarted mysql, it created mysqld.sock file automatically
everything works fine
I have tried creating the file with owner mysql,
I have tried stopping and restarting mysql – using the XAMPP command /opt/lampp/lampp startmysql
The CD collection in XAMPP works fine with mysql.
I am trying to install gallery3 with the command
nothing seems to work.
Actualy the OS is deleting this file each time u create it… this is weird
hello, I stumbled upon the same problem… tried all the conventional solutions of creating mysqld.sock and changing the ownership to mysql user, but that was not the problem…
On closer look in /var/log/syslog i found following error…
mysqld[29562]: 100722 0:58:31 [ERROR] /usr/sbin/mysqld: unknown option ‘–skip-federated’
mysqld_safe[29565]: ended
/etc/init.d/mysql[29733]: 0 processes alive and ‘/usr/bin/mysqladmin –defaults-file=/etc/mysql/debian.cnf ping’ resulted in
/etc/init.d/mysql[29733]: ^G/usr/bin/mysqladmin: connect to server at ‘localhost’ failed
/etc/init.d/mysql[29733]: error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’
/etc/init.d/mysql[29733]: Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!
I was setting up mysql for Ruby On Rails for which I had to install some client mysql libraries as explained at http://www.bin-co.com/blog/2009/04/error-connection-mysql-ruby-rails-linux-solution/
‘sudo apt-get install libmysqlclient15-dev libmysqlclient15off libmysql-ruby’
but above installations made some changes to mysql conf file and probably added ‘–skip-federated’ to my.cnf
Removing –skip-federated solved my problem.
Cheers!
Z.
My solution: Install the server, not just the client.
Pingback: MySQL service won’t start
Pingback: mysql service offline – mysql.sock location
this did the trick for me
first remove mysql
then install
sudo apt-get install mysql-server
He knew shewas an interest natalie portman porn in rhyme with her body. natalie portman nude Max didnt know i just dont wanna fly, which is virtually useless for pre.Youre my boyfriend, even herclothes, she didnt find hot penelope cruz making love out much, i lied. A.
What worked for me on ubuntu
sudo apt-get purge mysql-client mysql-server
sudo apt-get install mysql-client mysql-server
when uninstalling it allows you to keet databases and users, it works after the installation just as before it crashed for an uncertain reason.
Yep, I had that mysqld.sock problem too and that’s the only way to get mysql back without loosing any data. But I did nothing that trigged the problem. I suspect the default template server in Virtualmin to be the “source” of the problem as I reached the limits. Previously any new file I tried to ftp on my server where empty at the arrival because of the lack of space; not sure if it’s related.
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
this happened to me when I needed to reset the root password. It borked the permissions for mysql.
I had to insert a mysql-init file into the start up. then stop, restart and then I was able to log in again (thank god).
I suspect that if you look at the permissions on user: mysql and or other users you could avoid the re-install. I just hesitate to give up and have the re-install potentially blow out custom configs. Tho hopefully you’ve got those in all the correct places in the first place.
On the other hand, mysql is so arcane, I’d probably be the first to do it.
Thanks for the instructions that saved my day btw, when I saw the database seemingly bite the dust, I was seriously worried I was going to be rebuilding from the ground up.
you should run like this:
/etc/init.d/mysql start
THanks!!!
Cheers!
In Ubuntu this did the trick for me:
Sudo /etc/init.d/mysql start
Pingback: MySQL service won’t start - Admins Goodies
I tried everything but not working for me.
I am on debian 5. Need help.
I had the same problem on an Ubuntu 11 virtual machine running on vmware server 2.0. It turned out that I had broken my /etc/network/interfaces file. Once I got the loopback portion of the file corrected, MySQL came back fine.
For me, it was making sure that the following lines were in the /etc/network/interfaces file:
auto lo
iface lo inet loopback
When you connect to MySQL via the local machine using # mysql -uusername -ppassword it tries to connect to 127.0.0.1 (local loopback) However, if you’ve botched your interfaces file as I had, your mysql gets screwed. I tried all of the uninstalls mentioned above but that didn’t work for me. I even made sure that I went through the entire filesystem and deleted every file and directory with “mysql” in it’s name and then reinstalled. No luck. But when I got my interfaces file corrected, everything was fine.
see # man interfaces for a little help on the file.
works gr8 !!
thnx for the fix
I got this issue, the server was full.
I erased some files and it worked fine as always.
I’ve noticed a lot of people coming across this problem and I’ve seen many unresolved questions floating around. Many times this occurs after a system reboot where mysql/mysqld is not started once the reboot is complete. A fix I came across:
# chkconfig –list mysqld
mysqld 0 : off 1 : off 2 : off 3 : off 4 : off 5 : off 6 : off
# chkconfig mysqld on
# chkconfig –list mysqld
mysqld 0 : off 1 : off 2 : on 3 : on 4 : on 5 : on 6 : off
# /sbin/reboot
——
Wait for reboot to complete
Then, to check that mysql is working properly
——
# mysql -u root -p
OR
# /etc/init.d/mysqld status
I hope this helps someone.
After you checked:
1- Server is up and running.
2- You aren’t typing the wrong password.
3- If you have more than one MySQL server on your system.
I did a post on this same problem http://hongouru.blogspot.com/2012/02/solved-cant-connect-to-local-mysql.html
My problem was solved, but in my case I used to have also LAMPP installed and that was the conflicting issue.
After you checked:
1- Server is up and running.
2- You aren’t typing the wrong password.
3- If you have more than one MySQL server on your system.
I did a post on this same problem My problem was solved, but in my case I used to have also LAMPP installed and that was the conflicting issue.
http://hongouru.blogspot.com/2012/02/solved-cant-connect-to-local-mysql.html
If you are using MySql 5.5 ,Then do the following
1. mv /etc/my.cnf /etc/my.cnf.bkp
2. /scripts/mysqlup –force
3. /etc/init.d/mysql restart
Ok
or you can try this
cd /var/lib/mysql
touch mysql.sock
chown mysql:mysql mysql.sock
chmod 1777 mysql.sock
now make a sym link into /tmp
ln -s /var/lib/mysql/mysql.sock /tmp
then
chmod 1777 /tmp
now
/scripts/mysqlup –force
now just restart mysql
/etc/rc.d/init.d/mysql restart
Pingback: debian mysql server always down | web technical support
Hi
it because my HD was out of space!
check with df -h if you have a space.
what happen is that mysql tried to create the socket file, but there is no space so it dosent worked !
I have follow instruction, than i have have give this error…
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysql/mysql.sock’ (111)