23

I got an error while am up starting the mysql service.

/etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
start: Job failed to start

Kindly share your ideas...

1
  • 2
    You may need to go through mysql logs for exact errors. Also sudo status/restart/start mysql is the way to invoke upstart jobs OR You can do sudo service mysql start/restart/status. Dec 18, 2013 at 9:18

2 Answers 2

18

UBUNTU SOLUTION If you are using AWS (Amazon Hosting), I could probably facing a cloud problem. I had a Zpanel Server installed on the "free tier" plan, and my MySQL became very unstable.

Sometimes the best solution could be install all over again. (usually I try to make a snapshop, as soon as I have the server up and running)

Well, the other solution, could be only reinstall the MySQL. Usually this problem appear when you try to change something in the /etc/mysql/my.cnf.

To fix it (works most of time), you will need to follow some steps (these step will try to normalize the MySQL instance)

  • First, try to reboot the server (if it doesn't work, follow to the next steps):

    • sudo reboot
  • Other steps:

    • First, create a backup from you MySQL folder var/lib/mysql/, just to make sure your data will be safe:
    • sudo -i
    • cp -R /var/lib/mysql/ ~/mysql
  • After that, remove/purge MySQL (this will remove: php5-mysql, phpmyadmin and other libraries, so after the procedure, you will have to reinstall again.

    • sudo apt-get purge mysql-server-5.1 mysql-common
  • Remove the folder /etc/mysql/ and its content:

    • sudo rm /etc/mysql/ -R
  • Later on, check if the database files are still in the folder /var/lib/mysql/ and if they are not, then copy it back:

    • mkdir /var/lib/mysql/
      chown root:root /var/lib/mysql/ -R
      cd ~/mysql/
      cp * /var/lib/mysql/ -R
      
  • Okay, then install o mysql server again

    • apt-get install mysql-server
  • And finally install phpmyadmin and php5-mysql:

    • apt-get install php5-mysql
      apt-get install phpmyadmin
      
  • At last, restart the services and check if the status are okay now:

    • service apache2 restart
      service mysql restart
      

That's it! It should work. I hope it works for you! (don't worry about the old data.That's why we have backup it first)

3
  • 1
    Thank you! So many other people try to troubleshoot. I am a big fan of the mindset of, lets wipe it, and reinstall it! But I didn't want to loose my DB as my latest Backup was 1 day old but I made a ton of entries into DB. I used this and did not lose any DB information! Dec 3, 2015 at 23:16
  • In my case, I had to change permissions of /var/lib/mysql/ directory to mysql:mysql Apr 28, 2017 at 9:07
  • reboot worked for me (Ubuntu 14.04, mysql 5.5 to 5.7). Jun 27, 2017 at 21:36
13

In my case the problem turned out to be that I had no hard disk space left available. A log file had grown to epic proportions and I couldn't start MySQL due to lack of available space. Once I cleaned up the file and restarted, it worked fine.

1
  • 1
    /var/log/jenkins/jenkins.log grew up to 18GB out 20GB whole disk space :)
    – sobi3ch
    Dec 20, 2016 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .