LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-02-2007, 08:23 PM   #1
rwhite7890
LQ Newbie
 
Registered: Jun 2005
Posts: 28

Rep: Reputation: 15
MySQL Can Not Connect


Having trouble connecting to mysql from regular user. When I am root in shell and connect to mysql it allows me to conncect. When I switch to regular user, I can not and give me this error:

reg_user:~ > mysql -u root -p temp
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I have set my socket file to be /tmp/mysql.sock in the /etc/my.cnf file in both the [client] and [mysqld] sections. Also when I do a 'ps aux | grep mysql' I see that it is passed to the mysqld safe command as '/tmp/mysql.sock'.

I don't understand why when a regular user trying to connect it tries to use /var/lib/mysql/mysql.sock and when connecting via root user, it uses /tmp/mysql.sock.

Any suggestions?
 
Old 12-02-2007, 09:27 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
What are the permissions for the directory and socket that MySQL is using? I'd expect 0755 for /var/lib/mysql and 0777 for /var/lib/mysql/mysql.sock (although I'm using /var/run not /var/lib) - the directory and the socket are owned by mysql:mysql on my boxes.
 
Old 12-03-2007, 12:36 AM   #3
rwhite7890
LQ Newbie
 
Registered: Jun 2005
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks....the problem was that /etc/my.cnf did not have global read permissions. Fixed it and everything is ok.
 
Old 12-03-2007, 12:53 AM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Congrats - that's good news
 
Old 12-03-2007, 01:12 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
One problem is in your command.
Code:
reg_user:~ > mysql -u root -p temp
This should be either:
reg_user:~ > mysql -u root -ptemp

or

reg_user:~ > mysql -u root -p
temp

Also check if there are other my.cnf files, such as /etc/my.conf ~/reg_user/.my.cnf /root/.my.cnf or /mysql/datadir/my.cnf.
 
  


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. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
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 - Software

All times are GMT -5. The time now is 06:23 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