LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-16-2012, 10:55 AM   #1
chubbypama
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Rep: Reputation: Disabled
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.
 
Old 08-16-2012, 12:12 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,651

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by chubbypama View Post
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.
 
Old 08-16-2012, 12:23 PM   #3
chubbypama
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
in response to TB0ne

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:

Quote:
root@jPC:/run/mysqld# ps -ef|grep mysql
mysql 5297 1 0 Aug14 pts/0 00:05:12 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --skip-grant-tables --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
root 5298 1 0 Aug14 pts/0 00:00:00 logger -t mysqld -p daemon.error
mysql 5408 1 0 13:16 ? 00:00:00 /usr/sbin/mysqld
root 5671 29776 0 13:17 pts/0 00:00:00 grep --color=auto mysql
jj 26203 3430 0 10:18 ? 00:00:00 /usr/bin/kate -b /var/log/upstart/mysql.log


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

[1]+ Done mysqld_safe --skip-grant-tables
root@jPC:/run/mysqld#
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
 
Old 08-16-2012, 02:46 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,651

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by chubbypama View Post
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:
How is PHP getting involved in your MySQL query?
 
Old 08-16-2012, 03:12 PM   #5
chubbypama
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Exclamation response to TB0ne re: trying to restart mysql

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.

/var/lib/mysql
/var/lib/mysql/mysql
/var/log/mysql
/usr/lib/perl5/DBD/mysql
/usr/lib/perl5/auto/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/share/dbconfig-common/internal/mysql
/etc/init.d/mysql
/etc/apparmor.d/abstractions/mysql
/etc/mysql

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?
 
Old 08-16-2012, 03:20 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,651

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by chubbypama View Post
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.

/var/lib/mysql
/var/lib/mysql/mysql
/var/log/mysql
/usr/lib/perl5/DBD/mysql
/usr/lib/perl5/auto/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/share/dbconfig-common/internal/mysql
/etc/init.d/mysql
/etc/apparmor.d/abstractions/mysql
/etc/mysql

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.
 
Old 08-16-2012, 03:35 PM   #7
chubbypama
LQ Newbie
 
Registered: Aug 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
in response to TB0ne

Quote:
Originally Posted by TB0ne View Post
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.
 
Old 08-16-2012, 03:51 PM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,651

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by chubbypama View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Software 3 06-28-2007 11:46 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 03:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration