Mysql didn't startup after rebooting

After I rebooted my server, everything started up normally except for “mysql”, i tried to start it up manually “/etc/init.d/mysql restart” or with “service mysql restart“, it fails

In log file it says:

Jul 16 08:13:38 localhost /etc/init.d/mysql[18136]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Jul 16 08:13:38 localhost /etc/init.d/mysql[18136]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

I checked that path, but i didn’t find that socket file, please advise?

Edit:

root@myserver:/var/log# service mysql restart
 * Stopping MySQL database server mysqld                   [ OK ] 
 * Starting MySQL database server mysqld                   [fail]
Asked By: MohammedSimba

||

a simple hack:

sudo ln -s /var/run/mysql/mysql.sock /tmp/mysql.sock
sudo service mysqld restart

If this doesn’t work then try this:

First find open socket files for mysql in your system

sudo find / -type s 2>/dev/null | grep mysql 

For my case it’s /var/lib/mysql/mysql.sock

Then edit the configuration file /etc/my.cnf

sudo gedit /etc/mysql/my.cnf

Then search for socket and edit the entry with the output above

socket=/var/lib/mysql/mysql.sock
Answered By: Maythux

Try service mysql restart.
Ubuntu uses upstart for mysql service (see What's the difference between "Service" and "/etc/init.d/"?), and it’s behavior differs from init scripts.

What version of Ubuntu and Mysql are you using?
Could you please post above command output and /var/log/mysql*?

Answered By: gmy

I tried to startup mysql in “Safe Mode” to create the sock file and pid file, but it fails for some error “bind”,

  1. I changed the IP address in “bind ip” parameter in my.cnf to localhost
  2. started mysql in safe mode.
  3. restarted mysql in normal mode, and everything went fine.
Answered By: MohammedSimba

I faced with the same issue. And find out that:

  1. My Ubuntu MySQL Config file is in /etc/mysql/mysql.cnf
  2. That file includes all *.cnf file in /etc/mysql/mysql.conf.d and /etc/mysql/conf.d.
  3. the line: log-error = /var/log/mysql/error.log is very useful

Open two shell connection. Run this on first server:

  • tail -f /var/log/mysql/error.log

On second server, just restart mysql:

  • service mysql restart

See the error messages in the error log. In my case, it was these two lines:

  • query_cache_limit = 1M
  • query_cache_size = 16M

I simply comment them, and somehow the mysql can start again.

Answered By: Fandi Susanto
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.