LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 11-07-2007, 04:20 PM   #1
Devilz
LQ Newbie
 
Registered: Nov 2007
Distribution: openSUSE 12.1
Posts: 23

Rep: Reputation: 15
mySQL cannot connect, no mysql.sock file.


When I try to run mySQL on Fedora 7, it gives me an error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
There is no mysql.sock file on my system.
I have tried to run mysqld start, but that gives me an error:
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

I have searched through the forums, and the only solutions that I have found depend on one of the two commands to work.
I installed mysql, mysql-server and mysql-devel through yum.
Any ideas or suggestions would be greatly appreciated.
 
Old 11-07-2007, 09:33 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by Devilz View Post
When I try to run mySQL on Fedora 7, it gives me an error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
There is no mysql.sock file on my system.
I have tried to run mysqld start, but that gives me an error:
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

I have searched through the forums, and the only solutions that I have found depend on one of the two commands to work.
I installed mysql, mysql-server and mysql-devel through yum.
Any ideas or suggestions would be greatly appreciated.
Who are you running mysqld as? How are you launching mysqld? Does /var/lib/mysql exist? what are the permissions on that directory?

btw, I have a very detailed post on this forum about this error, but it's related to running mysql in user space where I don't have access to /var/lib. Your config is a little different, so let's get started by answering the above questions.
 
Old 11-08-2007, 12:02 AM   #3
Devilz
LQ Newbie
 
Registered: Nov 2007
Distribution: openSUSE 12.1
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by BrianK View Post
Who are you running mysqld as? How are you launching mysqld? Does /var/lib/mysql exist? what are the permissions on that directory?

btw, I have a very detailed post on this forum about this error, but it's related to running mysql in user space where I don't have access to /var/lib. Your config is a little different, so let's get started by answering the above questions.
I am running mysqld as root, using /etc/rc.d/init.d/mysqld.
/var/lib/mysql DOES exist.
This is the permissions I get using ls -l.
drwxr-xr-x 4 mysql mysql 4096 2007-11-07 13:54 mysql
However, when I go to the folder using the GUI, it says the owner is: mysql - MySQL Server, and it won't let me change any of the options (when I'm running as user).
Hopefully that's detailed enough.
 
Old 11-08-2007, 11:12 AM   #4
complich8
Member
 
Registered: Oct 2007
Distribution: rhel, fedora, gentoo, ubuntu, freebsd
Posts: 104

Rep: Reputation: 15
more to the point, does /var/lib/mysql/mysql.sock exist? How are the permissions on it?

Check your my.cnf in both the sections [mysql] and [mysqld] and make sure that they agree on where the socket should be. If they don't, then change the [mysql] section's socket to point to the [mysqld]'s one and try it again.

You might also check the output of "ps aux | grep mysql", looking for the "--socket" argument and making sure it matches what you expect.
 
Old 11-08-2007, 03:26 PM   #5
Devilz
LQ Newbie
 
Registered: Nov 2007
Distribution: openSUSE 12.1
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by complich8 View Post
more to the point, does /var/lib/mysql/mysql.sock exist? How are the permissions on it?

Check your my.cnf in both the sections [mysql] and [mysqld] and make sure that they agree on where the socket should be. If they don't, then change the [mysql] section's socket to point to the [mysqld]'s one and try it again.

You might also check the output of "ps aux | grep mysql", looking for the "--socket" argument and making sure it matches what you expect.
mysql.sock doesn't exist anywhere on my system.

Code:
ps aux | grep mysql
root      3261  0.0  0.0   4004   708 pts/0    S+   13:23   0:00 grep mysql
I don't know what you mean by using the "--socket" argument though.
 
Old 11-08-2007, 03:50 PM   #6
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by Devilz View Post
mysql.sock doesn't exist anywhere on my system.

Code:
ps aux | grep mysql
root      3261  0.0  0.0   4004   708 pts/0    S+   13:23   0:00 grep mysql
I don't know what you mean by using the "--socket" argument though.
re: ps aux -
mysqld is not running on your system. The only thing that you are grepping out of the ps is the call to ps itself. A properly running mysqld will have a ps entry looking something like so (though your paths will be different than mine):

Code:
ps aux | grep mysql
briank    5452  0.0  0.0   4968  1552 ?        S    Nov04   0:00 /bin/sh ./bin/mysqld_safe --user=briank --socket=/tmp/mysql.sock
briank    5480  0.0  0.4 110532 17176 ?        Sl   Nov04   3:27 /local/mysql/libexec/mysqld --basedir=/local/mysql --datadir=/local/mysql/var --pid-file=/local/mysql/var/akane.pid --skip-external-locking --port=3306 --socket=/tmp/mysql.sock
briank   15568  0.0  0.0   3644   724 pts/3    S+   13:46   0:00 grep mysql
though mysqld may not be starting *because* of the socket problem.

When I installed my mysql server by hand, the socket wasn't created until I ran the tests.. This is not to say that it wouldn't have been created by simply starting it, but it is to say that running the tests created the socket file.

to run the test, see if you have a directory called "mysql-test" somewhere on your system. If so, cd to that dir, then run "perl mysql-test-run.pl" (assuming you have perl installed).

Beyond that, double check your my.conf & see that everything looks sane (though it should as you have a vanilla install from yum); then try starting by hand, i.e.:

cd /wherever/mysql/root/is (probably / or /usr)
./bin/mysqld_safe --user=mysql

and see what happens. At least you'll see error messages on the screen this way.

Last edited by BrianK; 11-08-2007 at 03:55 PM.
 
Old 11-08-2007, 05:02 PM   #7
Devilz
LQ Newbie
 
Registered: Nov 2007
Distribution: openSUSE 12.1
Posts: 23

Original Poster
Rep: Reputation: 15
There is no "mysql-test" file on my system, however there is a mysqltest in /usr/bin.
Code:
perl mysqltest -run
Unrecognized character \x7F at mysqltest line 1.
My conf file looks fine as well.
Code:
[root@localhost bin]# mysqld_safe --user=mysql
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
071108 15:00:25  mysqld ended
 
Old 11-08-2007, 06:37 PM   #8
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by Devilz View Post
There is no "mysql-test" file on my system, however there is a mysqltest in /usr/bin.
Code:
perl mysqltest -run
Unrecognized character \x7F at mysqltest line 1.
weird. can't tell you what that means. If you look at the file (it should just be text) are there any odd chars in it on line 1?
Quote:
My conf file looks fine as well.
Code:
[root@localhost bin]# mysqld_safe --user=mysql
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
071108 15:00:25  mysqld ended
So from that, it appears that it started then stopped immediately. Did you stop it with cntl-c or did it stop by itself?

Either way, why don't you try specifying a socket when you launch mysqld by hand - just as a test.

mysqld_safe --user=mysql --socket=/tmp/mysql.sock

if it doesn't quit immediately, open another shell then connect with:

mysql --socket=/tmp/mysql.sock

... if you need to specify user/pass, then do:

mysql --socket=/tmp/mysql.sock -uuser -ppass


edit: I'm beginning to wonder if the initial database setup was ever done. is there anything in /var/lib/mysql? if so, what? Go ahead and do that other stuff too (the couple things above), but if that doesn't work, there's another road we can travel.

Last edited by BrianK; 11-08-2007 at 06:43 PM.
 
Old 11-09-2007, 04:51 PM   #9
Devilz
LQ Newbie
 
Registered: Nov 2007
Distribution: openSUSE 12.1
Posts: 23

Original Poster
Rep: Reputation: 15
^?ELF^A^A^A^@^@^@^@^@^@^@^@^@^B^@^C^@^A^@^@^@ðÁ^D^H4^@^@^@4^E^B^@^
There's the first few characters in the file. There is only about 2% that is in normal characters.
I tried the options, however I got the same result.
But the problem is probably that the databases weren't created (as you said).
In /var/lib/mysql, there is a mysql directory and a test directory, however they are both empty.
 
Old 11-09-2007, 05:01 PM   #10
complich8
Member
 
Registered: Oct 2007
Distribution: rhel, fedora, gentoo, ubuntu, freebsd
Posts: 104

Rep: Reputation: 15
http://dev.mysql.com/doc/refman/5.0/...tallation.html says that rpm distros run the mysql_install_db command. But if it didn't run (which, if those dirs are empty, it probably didn't run successfully), you might try running it yourself.

The rest of that document should also prove informative, if you run it successfully. It's sort of the "here's the next steps" doc.

Last edited by complich8; 11-09-2007 at 05:03 PM.
 
Old 11-09-2007, 05:37 PM   #11
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by complich8 View Post
http://dev.mysql.com/doc/refman/5.0/...tallation.html says that rpm distros run the mysql_install_db command. But if it didn't run (which, if those dirs are empty, it probably didn't run successfully), you might try running it yourself.
What he said.

... and it also appears that the file you quoted is binary. maybe you just run it as opposed to perling it. Regardless - try to do the initial db setup as described in the docs.
 
Old 05-24-2009, 05:39 AM   #12
fsf
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
mysql not starting in fedora 9

i have installed mysql using yum
yum install mysql
and its not started and when i try to run in terminal iam getting this message
"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"

var/lib/mysql doesnt exist

tried mysql_safe but did not worked
 
Old 05-24-2009, 07:25 AM   #13
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,034

Rep: Reputation: 97
Most probably this problem causes as the default database not created properly so try to install default database once again.
mysql_install_db --user=username
 
Old 05-25-2009, 12:03 AM   #14
complich8
Member
 
Registered: Oct 2007
Distribution: rhel, fedora, gentoo, ubuntu, freebsd
Posts: 104

Rep: Reputation: 15
"yum install mysql" will get you the client, but not the server.

"yum install mysql-server" gets you the server-side part of that.

Follow that up with a "/sbin/service mysql start" (or possibly /sbin/service mysqld start) and you should be good to go.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 15 04-25-2012 02:45 PM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' mohadesz Linux - Server 3 03-15-2008 05:06 AM
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 PM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' mathimca05 Linux - Newbie 2 10-17-2007 02:04 AM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) sunlinux Linux - Software 1 11-07-2006 12:08 AM


All times are GMT -5. The time now is 08:25 PM.

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
Open Source Consulting | Domain Registration