[SOLVED] getting the following error: Can't connect to local MySQL server through socket
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
getting the following error: Can't connect to local MySQL server through socket
I'm trying to reset my mysql password on my server, and i'm getting the following error message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
that's what i get when i try to run mysqld_safe --skip-grant-tables
I noticed that someone else posted the same question here a while ago but his problem was related to the fact that his hard disk was full and the system couldn't create files.
But that's not my problem. Any suggestions? Sorry if this is not the right place to post. I just noticed that someone posted their question here back in the day...
Thanks.
I'm trying to reset my mysql password on my server, and i'm getting the following error message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
that's what i get when i try to run mysqld_safe --skip-grant-tables
I noticed that someone else posted the same question here a while ago but his problem was related to the fact that his hard disk was full and the system couldn't create files. But that's not my problem. Any suggestions? Sorry if this is not the right place to post. I just noticed that someone posted their question here back in the day...
Thanks.
Well, the obvious suggestions would be to do as the error message says. IS MySQL running? Does the file exist?? You don't say what version/distro of Linux you're using, but usually running "sudo /etc/init.d/mysql status" will tell you if it's running or not. If it's not running...start it.
yes, i checked to make sure that mysql is started. i did try to google thisproblem before posting and the number one reason seems to be that mysql is not started.
so i did make sure that i started it.
I proved it to myself by doing the following:
Also, here's a list of additional observations;
1. If i leave the mysqld_safe request long enough, eventually it comes back with another message saying that it ended. Then when i hit enter, i get a prompt. i've posted the full output below.
Quote:
root@jPC:/run/mysqld# 120816 13:15:02 mysqld_safe Logging to syslog.
120816 13:15:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120816 13:16:42 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
As far as my environment is concerned, here's some info my phpinfo:
Version of Ubuntu: 3.2.0-29-generic-pae #46-Ubuntu
Active Persistent Links 0
Active Links 0
Client API version 5.5.24
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib/i386-linux-gnu -lmysqlclient_r
Directive Local Value Master Value
mysql.allow_local_infile On On
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
yes, i checked to make sure that mysql is started. i did try to google thisproblem before posting and the number one reason seems to be that mysql is not started. so i did make sure that i started it.
I proved it to myself by doing the following:
Have you tried to restart MySQL? Usually a "sudo /etc/init.d/mysql restart" will do it.
Quote:
Also, here's a list of additional observations;
1. If i leave the mysqld_safe request long enough, eventually it comes back with another message saying that it ended. Then when i hit enter, i get a prompt. i've posted the full output below.
It looks like the process is getting started in the background, then completing and exiting. And if you've already GOT MySQL running, trying to run it again on the same port will cause it to have issues. Try stopping the MySQL daemon first, then running your mysqld_safe command.
Quote:
As far as my environment is concerned, here's some info my phpinfo:
Yes. I had tried to restart many times.
tried both sudo /etc/init.d/mysql restart
and "service mysql stop" and then "service mysql start".
At one point, when i ran mysqld on it's own, i got an message saying that it couldn't lock ./ibdata1 or something along those lines. Found a post somewhere with instructions on how to use the debian sys admin account to somehow resolve this problem, but the guy who did the mysql install didn't have the right password for me!
So, as of right now, I'm stuck trying to uninstall / reinstall mysql and phpmyadmin.
I tried to uninstall by doing:
apt-get remove mysql-server
apt-get remove mysql-client
apt-get remove mysql-common
apt-get remove phpmyadmin
I noticed that there were still a bunch of folders around, so i renamed them from mysql to mysql.bad.
i renamed and kept them in their respective folders.
Then i tried to reinstall the packages but I'm noticing that the mysql server install doesn't ask me for a password.
Any ideas why?
Yes. I had tried to restart many times.
tried both sudo /etc/init.d/mysql restart
and "service mysql stop" and then "service mysql start".
Try STOPPING mysql through the init script, then running the mysqld_safe command (said that in my last post)
Quote:
At one point, when i ran mysqld on it's own, i got an message saying that it couldn't lock ./ibdata1 or something along those lines. Found a post somewhere with instructions on how to use the debian sys admin account to somehow resolve this problem, but the guy who did the mysql install didn't have the right password for me!
Why would ANYONE have the passwords for your system? And if you try to run mysqld as a non-root user, you'll get errors. You need to be root/sudo to do such things.
Quote:
So, as of right now, I'm stuck trying to uninstall / reinstall mysql and phpmyadmin.
I tried to uninstall by doing:
apt-get remove mysql-server
apt-get remove mysql-client
apt-get remove mysql-common
apt-get remove phpmyadmin
I noticed that there were still a bunch of folders around, so i renamed them from mysql to mysql.bad.
i renamed and kept them in their respective folders.
Then i tried to reinstall the packages but I'm noticing that the mysql server install doesn't ask me for a password.
Any ideas why?
Yes, because a fresh install of MySQL doesn't HAVE passwords. As root, run "mysql", and you're in. Re-installing is a last step, and was unnecessary.
Try STOPPING mysql through the init script, then running the mysqld_safe command (said that in my last post)
Why would ANYONE have the passwords for your system? And if you try to run mysqld as a non-root user, you'll get errors. You need to be root/sudo to do such things.
Yes, because a fresh install of MySQL doesn't HAVE passwords. As root, run "mysql", and you're in. Re-installing is a last step, and was unnecessary.
i did try running as root and then launching / running mysql. i still get the same erro message "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
I understand it's frustrating trying to help people, but you also have to appreciate that we're not all idiots. My network admin set up this box... and he set up passwords but couldn't remember them. I think you misunderstood my comment.
if you can help with the error message, that'd be great. if not, maybe someone else can. BTW. if you do a search for this error message, you'll otice that a few people have had this problem and it hasn't been so obvious to fix.
Last edited by chubbypama; 08-16-2012 at 03:36 PM.
i did try running as root and then launching / running mysql. i still get the same erro message "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
No...stop mysqld first, by means of the "/etc/init.d/mysql stop" command. THEN run the mysqld_safe command, and check out the man page on mysqld_safe. After the mysqld_safe command is completed, restart the mysql engine.
Quote:
I understand it's frustrating trying to help people, but you also have to appreciate that we're not all idiots. My network admin set up this box... and he set up passwords but couldn't remember them. I think you misunderstood my comment.
Didn't mean to even imply you were an idiot...I thought you asked someone in another forum what the password was. And you'd be surprised how often such questions come up.
Quote:
if you can help with the error message, that'd be great. if not, maybe someone else can. BTW. if you do a search for this error message, you'll otice that a few people have had this problem and it hasn't been so obvious to fix.
Again I'll point out that you can't have two instances of mysql running on the same port/box at the same time. If the engine is running (as is evidenced by the output of the ps command you ran previously), mysqld_safe won't run. Stop one to run the other.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.