3

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]
MohammedSimba
  • 848
  • 8
  • 20
  • 40

4 Answers4

1

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
Maythux
  • 84,289
0

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.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Apr 24 '23 at 14:45
  • Dear Community bot. Unfortunately, all of my answers came from trial and error. So i don't have any citation. – Fandi Susanto Apr 25 '23 at 16:27
0

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*?

gmy
  • 1
  • failed to restart please check output in edit, Mysql version:5.1.37, Ubuntu old: 9.10, mysql logs are empty, it is only logging into daemon.log – MohammedSimba Jul 16 '15 at 11:30
  • Add to /etc/mysql/my.cnf:

    log = /var/log/mysql.log and log-error = /var/log/mysql.err, restart and post /var/log/mysql*.

    – gmy Jul 16 '15 at 12:49
0

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.
MohammedSimba
  • 848
  • 8
  • 20
  • 40