ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
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?
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.
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
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.
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?
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
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.