0

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"

Agvorth
  • 2,459
  • 4
  • 29
  • 29
  • 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
  • Is there any relevant information in `/var/log/mysql.log` ? – user9517 Aug 18 '11 at 19:47
  • @Iain Yes, thanks. As it turns out there is. "Error writing file '/var/run/mysqld/mysqld.pid'" and "Can't start server: can't create PID file: No space left on device". I'm confused though because ps indicates the server IS running. But that's probably something to do with the issue. Anyway, now I'm working with I.T. to allocate more space in /var. – Agvorth Aug 18 '11 at 20:43

3 Answers3

2

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.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • 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
1

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

Alex
  • 7,939
  • 6
  • 38
  • 52
1

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.

-$

SparX
  • 1,924
  • 12
  • 10