LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 09-30-2004, 05:48 AM   #1
NoviceW
Member
 
Registered: Nov 2003
Distribution: Debian, SuSE,Ubuntu
Posts: 38

Rep: Reputation: 15
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
 
Old 09-30-2004, 09:43 AM   #2
dizzutch
Member
 
Registered: Sep 2004
Location: Worcester, MA USA
Distribution: Debian, Gentoo, Fedora FC2
Posts: 66

Rep: Reputation: 15
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.
 
Old 09-30-2004, 02:42 PM   #3
LordFrancis
Member
 
Registered: Sep 2004
Location: Victoria, BC
Distribution: debian testing
Posts: 53

Rep: Reputation: 15
I'm working with SuSE 9,1 and get the very same error!
so I'm interested too in the solution of this problem!
 
Old 09-30-2004, 02:54 PM   #4
LordFrancis
Member
 
Registered: Sep 2004
Location: Victoria, BC
Distribution: debian testing
Posts: 53

Rep: Reputation: 15
thanks!
It perfectly worked!
 
Old 01-30-2005, 06:32 PM   #5
NoviceW
Member
 
Registered: Nov 2003
Distribution: Debian, SuSE,Ubuntu
Posts: 38

Original Poster
Rep: Reputation: 15
NoviceW

You can find the solution here.

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

NoviceW
 
Old 02-21-2005, 01:35 PM   #6
djones
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Rep: Reputation: 0
Unhappy 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
 
Old 02-21-2005, 03:42 PM   #7
djones
LQ Newbie
 
Registered: Feb 2005
Posts: 2

Rep: Reputation: 0
Thumbs up

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.
 
Old 09-08-2006, 01:03 PM   #8
trebek
Member
 
Registered: Feb 2005
Location: Costa Rica
Distribution: Ubuntu, gOS, Debian & Slack 12
Posts: 426

Rep: Reputation: 30
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.
 
Old 09-08-2006, 01:33 PM   #9
trebek
Member
 
Registered: Feb 2005
Location: Costa Rica
Distribution: Ubuntu, gOS, Debian & Slack 12
Posts: 426

Rep: Reputation: 30
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?
 
Old 05-30-2007, 03:59 PM   #10
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 07-06-2007, 11:10 PM   #11
Amadeus
LQ Newbie
 
Registered: Oct 2006
Distribution: CentOS
Posts: 6

Rep: Reputation: 0
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.
 
Old 01-09-2008, 08:20 AM   #12
_x_MaD_x_
LQ Newbie
 
Registered: Jan 2008
Posts: 1

Rep: Reputation: 0
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???
 
Old 02-19-2008, 05:37 AM   #13
zyopensource
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Rep: Reputation: 0
I found this file was in /tmp/mysql.sock

Quote:
Originally Posted by _x_MaD_x_ View Post
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.
 
Old 01-19-2009, 09:01 AM   #14
maxvonseibold
Member
 
Registered: Mar 2006
Location: Oxford, UK.
Distribution: Debian, Ubuntu, RHEL5, OSX
Posts: 41

Rep: Reputation: 15
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.
 
Old 09-05-2010, 06:55 AM   #15
javi2401
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock welery Linux - Software 19 03-06-2014 07:19 AM
error: Can't connect to local MySQL server through socket J0sep Red Hat 20 07-13-2011 09:32 AM
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
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 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


All times are GMT -5. The time now is 04:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration