LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-08-2005, 06:24 AM   #1
davidh_uk
LQ Newbie
 
Registered: Jan 2005
Location: London, england
Distribution: Debian
Posts: 9

Rep: Reputation: 0
starting mysql client localhost not recognised?


I cant seem to start mysql without providing the IP number:
shell>mysql -h 127.0.0.1 -p #works fine
but
shell>mysql -h localhost -p #gives this error
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

I do have localhost in my /etc/hosts file.

I think the issue is that my mysql.sock file is at the default /tmp location but invoking mysql with a non-IP address makes it look in /var/lib/mysql & I dont know why or how to change it. Nor do I see why this would cause a difference between mysql's treatment of an IP number and an address name such as localhost in this scenario. This could be nothing to do with it of course

I start the server manually (For testing reasons) so I have no /etc/my.cnf so I must be using all default values for client and server.

TIA
 
Old 05-09-2005, 04:13 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
You could use the -S option to specify the path to the sock file. See "man mysql" for the full list of options.
 
Old 05-09-2005, 04:47 PM   #3
davidh_uk
LQ Newbie
 
Registered: Jan 2005
Location: London, england
Distribution: Debian
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by david_ross
You could use the -S option to specify the path to the sock file. See "man mysql" for the full list of options.
yup, that worked fine:
'shell>mysqladmin -S /tmp/mysql.sock variables -u david -p'
versus
'shell>mysqladmin variables -u david -p'

but I'd like to know what to change so I don't have to type all the -S stuff every time. Yea, I know, I just want it all
Thanks David:
 
Old 05-09-2005, 05:15 PM   #4
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Maybe if you have the line "skip-networking" in your mysql.conf you can comment it by removing the "#" at the beginning of the line.
 
Old 05-09-2005, 05:15 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
According to another thread on this board you can change a line in your /etc/my.conf file:
Code:
cat /etc/my.conf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
...
 
Old 05-10-2005, 01:31 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Quote:
Originally posted by jschiwal
According to another thread on this board you can change a line in your /etc/my.conf file:
You can also set it for client utilities:
Code:
[mysql]
socket=/var/lib/mysql/mysql.sock
So long as it is the same for client and server it should work.
 
Old 05-10-2005, 04:32 PM   #7
davidh_uk
LQ Newbie
 
Registered: Jan 2005
Location: London, england
Distribution: Debian
Posts: 9

Original Poster
Rep: Reputation: 0
all fixed now

It now works fine.
"shell>bin/mysqld --help" showed that mysqld was looking for the my.cnf file in /etc
but I put it in /etc/mysql/my.cnf and didn't pass it the "--defaults-file" option to tell it where to pick options up from. Thus it wasn't picking the .sock file up from /tmp and it was this which caused all the confusion.

Thanks to all for the tips that helped me resolve it
 
  


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
localhost.localdomain and mySQL? Dark Severance Red Hat 2 04-21-2005 01:21 PM
MySQL commands not recognised by PHP4 Christopher Linux - Software 1 12-09-2004 05:16 PM
mysql localhost problems tim1235 Linux - Software 4 09-28-2004 07:14 PM
MySql localhost jdmml Linux - Newbie 1 07-20-2004 04:01 PM
PHP/CGI as FTP client for localhost Gear_freak2000 Linux - Software 5 06-04-2003 08:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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