Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

MySQL version

mysql  Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i386) using readline 5.1

Restarted the machine. Then tried...

$ ps aux | grep mysql
mysql     3298  0.0  0.8 136772 17216 ?        Rl   12:13   0:00 
  /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql 
  --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking 
  --socket=/var/lib/mysql/mysql.sock
xxxxx    3311  0.0  0.0   4000   680 pts/1    R+   12:13   0:00 
  grep mysql
root      3461  2.3  0.0   4624  1232 ?        S    11:55   0:26 
  /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql 
    --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log 
    --pid-file=/var/run/mysqld/mysqld.pid --user=mysql

So mysqld is running.

However I can't make a client connection to it...

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

When I try to connect from a different machine using Sequel Pro I get the error...

"MySQL said: Lost connection to MySQL server at 'reading initial communication packet', system error: 61"

share|improve this question
    
And what does netstat -an | fgrep ":3306" say? –  mailq Aug 18 '11 at 19:28
    
Just blank -- returns to the prompt with no message. –  Agvorth Aug 18 '11 at 19:29
    
do you get the same if you add -h 127.0.0.1 (in case it's an ipv4 vs ipv6 thing...) err n/m, just saw your answer to the netstat –  sandroid Aug 18 '11 at 19:30
    
And what's in the mysql error log? –  EightBitTony Aug 18 '11 at 19:32
    
Probably nothing. But when the netstat output is empty, then there is no socket listening on the mysql port. That means configuration error or the daemon never started the mysql engine or hangs while doing so. –  mailq Aug 18 '11 at 19:37

3 Answers 3

up vote 2 down vote accepted

The message ERROR 2002 (HY000): generally means that mysqld isn't running.

From the comments : the message "Error writing file '/var/run/mysqld/mysqld.pid'" appears in mysql.log

Solution:

The device holding your /var filesystem is full and the mysqld.pid file cannot be created so mysqld isn't starting.

Create some space on your /var filesystem.

share|improve this answer
    
Thanks. Yes that was the problem. I worked with I.T. to add more space and now MySQL is running OK. –  Agvorth Aug 18 '11 at 21:58

Try to run mysql using mysqld_safe --console from a command prompt, it won't detach from a terminal then. Check the console for errors, also check the logfile for errors too (it will print an absolute path to the logfile on the console, something like 110818 23:53:57 mysqld_safe Logging to '/var/log/mysqld.log'.). Of course you should stop your existing mysql instance before running mysqld_safe --console

share|improve this answer

Kill the mysqld & mysqld_safe processes with kill (try with 15 first and if it cannot stop, try 9) and try to restart mysql then. Also make sure that mysql is not bind to a specific IP.

-$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.