LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. (https://www.linuxquestions.org/questions/linux-networking-3/error-2002-cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-237016/)

NoviceW 09-30-2004 05:48 AM

ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.
 
Hi

I have installed mysql, using YAST and trying to issue basic commands. But I always get the following error messege.

ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I did check the "/var/lib/mysql/mysql.sock" file but it wasn't there. This can be my problem. However I have no idea how I could re-create the myssql.sock file. Can someone help me please?

Thank you in advance.
NoviceW

dizzutch 09-30-2004 09:43 AM

Sounds like MySQL isn't running, try running 'mysqld_safe &' and see if that fixes things, i'm not sure where it's located on your distribution. But that works for the source release.

LordFrancis 09-30-2004 02:42 PM

I'm working with SuSE 9,1 and get the very same error!
so I'm interested too in the solution of this problem!

LordFrancis 09-30-2004 02:54 PM

thanks!
It perfectly worked! ;)

NoviceW 01-30-2005 06:32 PM

NoviceW
 
You can find the solution here.

http://www.linuxguide.blogspot.com/

NoviceW

djones 02-21-2005 01:35 PM

Mysql error 2002 Can't connect
 
I also get the error and mysqld is running. I am trying to install a mediawiki and the installation looks for the mysql.sock file in /var/lib/mysql/ directory. The file is in the /tmp/ directory. Not in the other place. I have moved it and Mysqladmin stops working I can configure it to start in a different place but it would be easier to configure the media wiki to run from the original file location /tmp/mysql.sock any help would be welcome

THanks in advance
djones@authentidate.com

djones 02-21-2005 03:42 PM

I have found a configure file that is in /etc. It has the references to where mysql and clients get there mysql.sock. the file name is my.cnf. When I configured the client to look at the /tmp/mysql.sock the application (mediawiki) finished its self configuration. So off to the races.

trebek 09-08-2006 01:03 PM

I don't know how it worked for you guys, but i still can't get mysql to start up again. Can somebody explain a bit more what to do exactly???

The computer shows me that exact same error that you have specified, and i am running red hat 9.

trebek 09-08-2006 01:33 PM

Quote:

Originally Posted by dizzutch
Sounds like MySQL isn't running, try running 'mysqld_safe &' and see if that fixes things, i'm not sure where it's located on your distribution. But that works for the source release.

From where do i run the mysqld_safe command? I still can't get mysql to start up?

paulsm4 05-30-2007 03:59 PM

mysql connect error 2002
 
Hi -

I realize this post is rather old...
but since it popped up #1 on Google, and since it's been added to several times already...
I thought I might just as well add my $0.02:

1. The error "ERROR 2002: Can't connect to local MySQL server through socket" can actually mean a couple of completely different things:

a) MySQL isn't running (in which case the socket file won't exist)
... OR ...
b) The Linux user doesn't have permissions to access the file

2. The first thing to do, of course, is to verify that mysqld is running. The previous posters discussed that at length.

3. As far as permissions, this worked for me:
a) Make sure the socket file is group "mysql":
Quote:

ls -ld /var/lib/mysql.sock =>
srwxrwxrwx 1 mysql mysql 0 May 25 13:30 /var/lib/mysql/mysql.sock
<= This might give "permission denied"
b) Make sure you're a member of "mysql" group
[quote] groups
users[quote]

c) If you're not, add yourself:
Quote:

usermod -G mysql USE_YOUR_NAME_HERE
<= Note the capital "G"
d) Finally, I had to manually set permissions on /var/lib/mysql:
Quote:

ls -ld /var/lib/mysql
drwx------ 10 mysql mysql 1024 May 25 13:30 /var/lib/mysql
<= The default permissions only allowed user "mysql": nobody else!
Quote:

chmod g+rwx /var/lib/mysql
ls -ld /var/lib/mysql
drwxrwx--- 10 mysql mysql 1024 May 25 13:30 /var/lib/mysql
<= After running "chmod g+rwx" and adding myself to "mysql" group, I was finally able to connect

Amadeus 07-06-2007 11:10 PM

Quote:

Originally Posted by djones
I have found a configure file that is in /etc. It has the references to where mysql and clients get there mysql.sock. the file name is my.cnf. When I configured the client to look at the /tmp/mysql.sock the application (mediawiki) finished its self configuration. So off to the races.

thanks =) This was the ticket for me.

_x_MaD_x_ 01-09-2008 08:20 AM

Hi all
I'm having the same ERROR mensage with my opensuse but the problem is that I haven't this file /var/lib/mysql/mysql.sock
what can I do???

zyopensource 02-19-2008 05:37 AM

I found this file was in /tmp/mysql.sock
 
Quote:

Originally Posted by _x_MaD_x_ (Post 3016650)
Hi all
I'm having the same ERROR mensage with my opensuse but the problem is that I haven't this file /var/lib/mysql/mysql.sock
what can I do???

were you using the words"yum install mysql"installing mysql?if you were,
you can find this file in /tmp/mysql.sock.But I don't still solve this questions.

maxvonseibold 01-19-2009 09:01 AM

This link explains this perfectly:-

http://www.tech-recipes.com/rx/762/s...-tmpmysqlsock/


In short. Mysql is expecting to find the socket in a different place. You can specify its location in /etc/my.cnf


Code:

[root@localhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql

socket=/tmp/mysql.sock
#socket=/var/lib/mysql/mysql.sock

user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]#

Here I have commented out the old socket location and added the new one.

It worked immediately.

javi2401 09-05-2010 06:55 AM

Hey guys it was a lot more easy for me to get it to work: the thing was mysql service wasn't running, so the only thing I did was:
$ service mysql start
and that was it! after that I could start myslq with no problems
I'm using opensuse 11.2


All times are GMT -5. The time now is 05:06 PM.