MySQL Job failed to start
Asked Answered
N

13

20

I'm on Kubuntu 12.04, and after installing mysql via an apt-get (mysql ver: 5.5.35), i'm trying to start mysql service, but I got this error:

sudo service mysql start

start: Job failed to start

So I googled this problem, it says i have to go to the /var/log/mysql/error.log

But my error.log file is empty :(

Then I checked the permissions :

drwxr-s--- 2 mysql adm 4096 Apr 7 11:21 mysql

-rw-r----- 1 mysql adm 0 Apr 7 11:21 error.log

So I don't know what to do... Why this error ? Why is the error file empty ?

Nickel answered 7/4, 2014 at 9:55 Comment(0)
A
49

First make a backup of your /var/lib/mysql/ directory just to be safe.

sudo mkdir /home/<your username>/mysql/
cd /var/lib/mysql/
sudo cp * /home/<your username>/mysql/ -R

Next purge MySQL (this will remove php5-mysql and phpmyadmin as well as a number of other libraries so be prepared to re-install some items after this.

sudo apt-get purge mysql-server-5.1 mysql-common

Remove the folder /etc/mysql/ and it's contents

sudo rm /etc/mysql/ -R

Next check that your old database files are still in /var/lib/mysql/ if they are not then copy them back in to the folder then chown root:root

(only run these if the files are no longer there)

sudo mkdir /var/lib/mysql/
sudo chown root:root /var/lib/mysql/ -R
cd ~/mysql/
sudo cp * /var/lib/mysql/ -R

Next install mysql server

sudo apt-get install mysql-server

Finally re-install any missing packages like phpmyadmin and php5-mysql.

Antitoxin answered 7/4, 2014 at 10:1 Comment(12)
what would be the reason of such a crash ? mysql is pretty stable… It happened to meGrazing
@Grazing :This problem may be occurred due to improper installation or uninstall .If you are installed first time in your system it will not occur . There might be some dependencies that are not properly removed completely when you re-installing mysql.Antitoxin
I'm very proccupied then.. my mysql install was running for like more than a year, i've upgraded ubuntu then the mysql to 5.5 about a month ago. Never had any problems. Meaning someone made his way into my server you think ?Grazing
@Grazing :After you upgraded ubuntu did you installed mysql once again ?Antitoxin
I upgraded all the packages (don't remember the command). But not explicitly mysql by itself. My worry is that it had been running like this for more than a monthGrazing
Just do the sudo apt-get purge mysql-server-5.1 mysql-common followed by sudo apt-get install mysql-serverTumblebug
Have people realized that just rebooting might solve this issue? It worked for me and I think it should be the first attempt before performing these steps.Rencontre
E: Sub-process /usr/bin/dpkg returned an error code (1) when sudo apt-get install mysql-server. Should have tried rebooting first...Starstarboard
After I finally solved all the issues and succesfully reinstalled mysql-server, I found that my data have all lost!!! The data I have copied via sudo cp * /home/<your username>/mysql/ -R is the same with /var/lib/mysql/, which is of no usage. This is a very dangerous and bad answer!Starstarboard
REMEMBER to use apt-get update and apt-get upgrade if server not upgraded, because att-get install mysql-server will trigg many errors if not consistent... That was my problem.Futurity
will my existing databases be safe ?Figureground
I had same problem for mysql 5.7 and worked properly too, no databases lost, thanks @AntitoxinSpeiss
F
10

My problem was running out of memory. Digital ocean has great instruction for adding swap memory for Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

This solved the issue and enabled me to restart the Mysql that otherwise would not start.

Francinafrancine answered 24/4, 2015 at 20:45 Comment(0)
S
6

Reinstallation will works because it will reset all the value to default. It is better to find what the real culprits (my.cnf editing mistake does happens, e.g. bad/outdated parameter suggestion during mysql tuning.)

Here is the mysql diagnosis if you suspect some value is wrong inside my.cnf : Run the mysqld to show you the results.

sudo -u mysql  mysqld 

Afterwards, fix all the my.cnf key error that pop out from the screen until mysqld startup successfully.

Then restart it using

sudo service mysql restart
Scrope answered 11/11, 2016 at 14:12 Comment(0)
C
5

In my case, it simply because the disk is full. Just clear some disk space and restart and everything is fine.

Coryden answered 2/8, 2017 at 2:24 Comment(2)
In my case too. Thanks.Becnel
Idem. You saved me from a valley of tears. ThanksLorenzoloresz
T
3

In most cases, just purging the mysql-server package and re-installing it will do the job.

Run,

sudo apt-get purge mysql-server-5.1 mysql-common

followed by

sudo apt-get install mysql-server

Tumblebug answered 29/8, 2015 at 6:1 Comment(0)
R
2

This line did solve the issue in my case,

sudo apt clean
Rough answered 9/12, 2017 at 12:7 Comment(0)
T
1

In my case, i do:

  1. sudo nano /etc/mysql/my.cnf
  2. search for bind names and IPs
  3. remove the specific, and let only localhost 127.0.0.1 and the hostname
Trinidad answered 23/8, 2016 at 18:30 Comment(1)
How do i search bind ?Tollbooth
N
1

Check the file permissions, if edited

Fail:

$ sudo chmod 776 /etc/mysql/my.cnf
$ sudo service mysql restart
mysql stop/waiting
start: Job failed to start

Ok:

$ sudo chmod 774 /etc/mysql/my.cnf
$ sudo service mysql restart
stop: Unknown instance:
mysql start/running, process 9564
Net answered 11/7, 2017 at 13:3 Comment(0)
M
1

To help others who do not have a full disk to troubleshoot this problem, first inspect your error log (for me the path is given in my /etc/mysql/my.cnf file):

tail /var/log/mysql/error.log

My problem turned out to be a new IP address allocated after some network router reconfiguration, so I needed to change the bind-address variable.

Mira answered 20/4, 2019 at 2:38 Comment(0)
T
1

In my case the problem was the /var/log disk full (check with df -h)

Just deleted some log files and mysql started, no big deal!

Tracheostomy answered 27/8, 2020 at 14:26 Comment(0)
T
0

The given solution requires enough free HDD, the actual problem was the HDD memory shortage. So If you don't have an alternative server or free disk space, you need some other alternative.

I faced this error with my production server (Linode VPS) when I was running a bulk download into MySQL. Its not a proper solution but VERY QUICK FIX, which we often need in production to bring things UP FAST.

  1. Resize our VPS Server to higher Hard Disk size
  2. Start MySQL, it works.
  3. Login to your MySQL instance and make appropriate adjustments that caused this error (e.g. remove some records, table, or take DB backup to your local machine that are not required at production, etc. After all you know, what caused this issue.)
  4. Downgrade your VPS Server to previous package you was already using
Trace answered 18/1, 2015 at 7:25 Comment(0)
G
0

In my case:

  • restart server
  • restart mysql
  • create .socket in directory
Galingale answered 29/9, 2016 at 16:24 Comment(1)
please have more details, where to create .socket directoryMensal
S
0

I had the same problem. But i discover that my hd is full.

$ sudo cat /var/log/upstart/mysql.log
/proc/self/fd/9: ERROR: The partition with /var/lib/mysql is too full!

So, I run

$ df -h

And I got the message

/dev/xvda1      7.8G  7.4G     0 100% /

Then I found out which folder was full by running the following command on the terminal

$ cd /var/www
$ for i in *; do echo $i; find $i |wc -l; done

This give me the number of files on each folder on /var/www. I logged into the folder with most files, and deleted some backup files, and i continued deleting useless files and cache files.

then I run $ sudo /etc/init.d/mysql start and it work again

Salty answered 26/8, 2018 at 5:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.