LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-16-2003, 08:54 PM   #1
meluser
Member
 
Registered: Mar 2003
Posts: 65

Rep: Reputation: 15
error 2002, loging into MySQL. please help


hi

i am getting this error logging into my mysql using root:


[root@cctv me]# mysql -u root -p
Enter password:
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/m
ysql.sock' (2)
[root@cctv me]#

cheers
Mel
 
Old 03-16-2003, 09:01 PM   #2
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
Are you sure its running?

what does:

"netstat -pant|grep mysql"

get you back?

What happens if you just type:

"mysql"

and just hit enter?
 
Old 03-16-2003, 09:03 PM   #3
jdc2048
Member
 
Registered: Jul 2002
Location: Ohio, USA
Distribution: Redhat, Gentoo, Solaris, HP-UX, etc...
Posts: 391

Rep: Reputation: 30
I am not using mysql myself (using postgresql), but perhaps a few extra details will help.

1. Are you running mysql in a chroot jail?

2. Are you connecting to a remote mysql server?

2.1 Do you have any ipchains allowing/preventing connections on mysql port?

3. Distro, mysql version, etc...

4. does the file /var/lib/mysql/mysql.sock exist?

5. Any other relevant information? (I.E. it worked before i added <package>, it has not ever worked before, it works when logged in as <user>, i've read and followed the how-to/readme/install, etc..)

Last edited by jdc2048; 03-16-2003 at 09:04 PM.
 
Old 03-16-2003, 09:04 PM   #4
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
Hi

this is what i get:
___________________________________________

[root@cctv run]# netstat -pant|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
13392/mysqld
tcp 0 0 134.36.16.12:3306 217.225.232.197:3310 ESTABLISHED
13392/mysqld
[root@cctv run]# netstat -pant|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 13392/mysqld
tcp 0 0 134.36.16.12:3306 217.225.232.197:3310 ESTABLISHED 13392/mysqld
[root@cctv run]#


------

[root@cctv run]# mysql
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@cctv run]#
 
Old 03-16-2003, 09:08 PM   #5
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
hi,

>>1. Are you running mysql in a chroot jail?
whats this?

>>2. Are you connecting to a remote mysql server?
yes

>>2.1 Do you have any ipchains allowing/preventing connections >>on mysql port?
i dont understand

>>3. Distro, mysql version, etc...
3.22

>>4. does the file /var/lib/mysql/mysql.sock exist?

[root@cctv run]# locate mysql.sock
/var/lib/mysql/mysql.sock
[root@cctv run]#

>>5. Any other relevant information? (I.E. it worked before i >>added <package>, it has not ever worked before, it works >>when logged in as <user>, i've read and followed the how->>to/readme/install, etc..)

It was working fine, i dont know what the problem is. i have a perl script that insert data in mysql, and php to take data out. but it was working fine.


thanks for the help
 
Old 03-16-2003, 09:12 PM   #6
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
Ok so we know its running on a port and that its not a permissions problem.

Try:

mysql -u root -h localhost


I think its looking for a socket when it should be looking for a port.
 
Old 03-16-2003, 09:13 PM   #7
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
same error:

------------------------------
[root@cctv run]# mysql -u root -h localhost
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@cctv run]#
 
Old 03-16-2003, 09:20 PM   #8
jdc2048
Member
 
Registered: Jul 2002
Location: Ohio, USA
Distribution: Redhat, Gentoo, Solaris, HP-UX, etc...
Posts: 391

Rep: Reputation: 30
if you don't know what a chroot jail is, then I will assume that you are not using one. Basically, you can use the chroot command to run a program in an alternate root environment for security purposes.

What are the permissions on /var/lib/mysql/mysql.sock?

What user are you using currently?

Seriously consider if there were _any_ changes to the system. This is one of the most common culprits in something not working that used to work.

Also post the output of "file /var/lib/mysql/mysql.sock", although we may get the answer from the "ls -l /var/lib/mysql/mysql.sock"
 
Old 03-16-2003, 09:21 PM   #9
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/m
ysql.sock' (2)
[root@cctv me]#
 
Old 03-16-2003, 09:27 PM   #10
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
[root@cctv /]# ls -l /var/lib/mysql/mysql.sock
ls: /var/lib/mysql/mysql.sock: No such file or directory
[root@cctv /]# locate mysql.sock
/var/lib/mysql/mysql.sock
[root@cctv /]# cd /var/lib/mysql
[root@cctv mysql]# ls
cctvimages example mysql test
[root@cctv mysql]# ls -la
total 24
drwxr-xr-x 6 mysql mysql 4096 Mar 16 08:40 .
drwxr-xr-x 16 root root 4096 Mar 3 01:14 ..
drwx------ 2 mysql mysql 4096 Mar 10 18:02 cctvimages
drwx------ 2 mysql mysql 4096 Mar 4 00:03 example
drwx------ 2 mysql mysql 4096 Mar 3 01:25 mysql
drwx------ 2 mysql mysql 4096 Mar 3 01:25 test
[root@cctv mysql]#
 
Old 03-16-2003, 09:33 PM   #11
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
i dont understand what is happening:

[root@cctv mysql]# locate mysql.sock
/var/lib/mysql/mysql.sock
[root@cctv mysql]#

thanks
 
Old 03-16-2003, 09:46 PM   #12
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
Try restarting it. Looks like the socket it needs to connect on got removed somehow.
 
Old 03-16-2003, 09:50 PM   #13
jdc2048
Member
 
Registered: Jul 2002
Location: Ohio, USA
Distribution: Redhat, Gentoo, Solaris, HP-UX, etc...
Posts: 391

Rep: Reputation: 30
Ok, the file doesn't exist. The locate command is using an outdated list of files. Running the updatedb command will update your list that locate searches through.

The file (socket) may be created automatically when you start a mysql session. If this is the case, we have a problem with permissions, because the directory "/var/lib/mysql is owned by "mysql" and the permissions are set to allow write to only the owner. If you want to access mysql as root, then you will need to change the permissions on this directory to allow this.

possible solutions:
1. change the group owner to "root" and add write access to the group with the following commands.
Code:
chgrp root /var/lib/mysql
chmod g+w /var/lib/mysql
2. change the world permissions to allow write access to the directory (far less secure and not recommended)
Code:
chmod o+w /var/lib/mysql
<edit>
What m0rl0ck suggested about restarting may fix this problem. If you have this option, then go ahead and try it. If you can't spare the downtime, then you can try connecting as user "mysql" or follow the previous steps above.

Last edited by jdc2048; 03-16-2003 at 09:55 PM.
 
Old 03-16-2003, 10:57 PM   #14
meluser
Member
 
Registered: Mar 2003
Posts: 65

Original Poster
Rep: Reputation: 15
thanks for the help.

i restarted the server machine, and guess what it is working!!

thanks for the help. could you explain to me why would somthing happened, if possible.
 
  


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
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 03:13 PM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 02:52 AM
error while loging in linux pragti Programming 2 06-09-2004 03:54 AM
MySql error 2002, Cannot start mysql djchris Linux - Software 5 04-13-2004 07:12 PM
I am getting an Error 2002 when installing Mysql blanderson Linux - Newbie 0 10-16-2003 01:11 PM


All times are GMT -5. The time now is 08:37 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration