Today I did a fresh install of ubuntu 12.04 and went about setting up my local development environment. I installed mysql and edited /etc/mysql/my.cnf to optimise InnoDB but when I try to restart mysql, it fails with a error:

[20:53][tom@Pochama:/var/www/website] (master) $ sudo service mysql restart
start: Job failed to start

The syslog reveals there is a problem with the init script:

> tail -f /var/log/syslog

Apr 28 21:17:46 Pochama kernel: [11840.884524] type=1400 audit(1335644266.033:184): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=760 comm="apparmor_parser"
Apr 28 21:17:47 Pochama kernel: [11842.603773] init: mysql main process (764) terminated with status 7
Apr 28 21:17:47 Pochama kernel: [11842.603841] init: mysql main process ended, respawning
Apr 28 21:17:48 Pochama kernel: [11842.932462] init: mysql post-start process (765) terminated with status 1
Apr 28 21:17:48 Pochama kernel: [11842.950393] type=1400 audit(1335644268.101:185): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=811 comm="apparmor_parser"
Apr 28 21:17:49 Pochama kernel: [11844.656598] init: mysql main process (815) terminated with status 7
Apr 28 21:17:49 Pochama kernel: [11844.656665] init: mysql main process ended, respawning
Apr 28 21:17:50 Pochama kernel: [11845.004435] init: mysql post-start process (816) terminated with status 1
Apr 28 21:17:50 Pochama kernel: [11845.021777] type=1400 audit(1335644270.173:186): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=865 comm="apparmor_parser"
Apr 28 21:17:51 Pochama kernel: [11846.721982] init: mysql main process (871) terminated with status 7
Apr 28 21:17:51 Pochama kernel: [11846.722001] init: mysql respawning too fast, stopped

Any ideas?

Things I tried already:

I googled and found a Ubuntu bug with apparmor (https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/970366), I changed apparmor from enforce mode to complain mode:

sudo apt-get install apparmor-utils
sudo aa-complain /usr/sbin/mysqld
sudo /etc/init.d/apparmor reload

but it didn't help. I still can't start mysql.

I also thought the issue may be because the InnoDB logfiles were a different size than mysql was expecting. I removed the innodb log files before restarting using: sudo mv /var/lib/mysql/ib_logfile* /tmp. No luck though.

Workaround: I re-installed 12.04, made sure not to touch /etc/mysql/my.cnf in any way. Mysql is working so I can get on with what I need to do. But I will need to edit it at some point - Hopefully I'll have figured out a solution, or this question will have been answered by that point...

18 Answers 18


I finally figured out the issue. Basically, the definition of some parameters has been removed from the previous version of mysql and has been replaced with different names. To fix, in /etc/mysql/my.cnf, replace:

# Tom Added to ensure the server character set is set to utf8
default-character-set = utf8
default-collation     = utf8_general_ci


# Tom Added to ensure the server character set is set to utf8
character_set_server  = utf8
collation_server      = utf8_general_ci

This is the associated launchpad bug report: https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/958120.

Or easily run:

# Miraz added dpkg-reconfigure
dpkg-reconfigure mysql-server-5.5

But make sure there's no old mysql version installation installed, if there was please remove:

# Miraz quick mysql package check
dpkg -l *mysql*
  • I did not have this problem, but a dpkg-reconfigure mysql-server-5.5 fixed whatever was wrong in my config. Apr 15, 2014 at 6:10
  • in my case, the problem turned out to be a mistyped property name in /etc/mysql/my.cnf....From this blog: dangtrinh.com/2014/05/… , run mysqld -v. I tried googling mysql exit code 7, without success. My guess is exit code 7 has to do with failures to parse the mysql configuration file.
    – MaasSql
    Mar 16, 2015 at 15:21
  • I had this same issue but found it difficult to trace because my faulty configuration was under /etc/mysql/conf.d/* and also because there were old logs called /var/log/mysql.* which caused me not to notice the active logs /var/log/mysql/*.
    – Dave Burt
    Mar 25, 2015 at 0:24
  • 1
    side note: utf8_unicode_ci is better. Now even utf8mb4_unicode_ci
    – Akshay
    May 4, 2019 at 6:26

Innodb has a default setting (innodb_buffer_pool_size) which is set to 128M - this may be too large for your server (especially if you're using a small Amazon EC2 AMI - which I was) The fix that worked for me was to add the following line to /etc/mysql/my.cnf

innodb_buffer_pool_size = 16M

I wrote about this fix over here http://www.mlynn.org/2012/07/mysql-5-5-on-ubuntu-12-04-job-failed-to-start

  • Turns out my VM was just plain running out of memory. Setting innodb_buffer_pool_size lower was one part of the solution, but beware you might just be out of memory.
    – thaddeusmt
    Jan 8, 2015 at 17:47

I had a similar problem. It was frustrating because I couldn't see any error logs indicating what the problem was.

In my case, the value I had set for innodb_buffer_pool_size was too large for the memory of the server.

I found this out by running mysqld directly as the mysql user.

# su mysql
# mysqld

This way you actually see the error output.

  • 2
    This is a great tip, I'd been struggling to get some meaningful debug information out of mysql. Thanks! May 23, 2013 at 19:29

I also had a similar problem. The items below say they have been removed from mysql server 5.5.
If you have them in your my.cnf, it won't start. Comment them out with #.
(Info derived from : http://dev.mysql.com/doc/refman/5.5/en/replication-options-slave.html)

The options affected are shown in this list:

  • Perfect! Exactly what was throwing me off. Thanks.
    – Jim
    Mar 25, 2013 at 22:25

It seems to boil down to errors in the MySQL configuration, located in /etc/mysql/my.cnf and files in /etc/mysql/conf.d/.

In my case it was a wrong bind-address value, because the IP address of my machine had changed and MySQL couldn't bind anymore. Feel free to rea more on this in this blog article.


A good way to debug the failures in the post-start process (/etc/init/mysql.conf) is to check the upstart logs:

sudo tail -f /var/log/upstart/mysql.log 

That gave me a socket error:

error: 'Can't connect to local MySQL server through socket

In my case it was caused by a missing user setting under the [mysqld] group in my.cnf


When I had a similar MySQL error ("Job failed to start") after upgrading from 11.10 to 12.04, comment #27 on https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.1/+bug/573318?comments=all worked perfectly for me. Quote:

The problem for me was that the file /etc/apparmor.d/local/usr.sbin.mysqld did not exist after the upgrade. I manually copied one from one of the empty ones (i.e. only had header comment) and then everything was good to go.


For me the solution was to remove the line ...

set-variable = max_connections=200

... which is MySQL 3.x syntax and needs to be changed to


I had the same issue. It turned out to be the mysql my.cnf master slave replications. Check your /var/log/mysql/error.log.

I hope that's a little help. Check the mysql settings first before you waste two hours with apparmor which just works fine.


I had the same issues, for me the bind-address was set improperly in my /etc/mysql/my.cnf file. So it seems anything that isn't right in the my.cnf can cause this issue. I haven't found anything in the logs that indicated this as the issue.


My problem was 0% of free space! Double check :-)


Check the /tmp permissions. I had this problem, after many time googleing and restarts, i found out that /tmp permissions was 755.

I change it to 777 and mysql start well.

  • this thing in ancient but this was my problem....dunno how it changed...
    – TheHidden
    Oct 23, 2015 at 10:13
  • in some cases, by changing file system or mounting the /tmp on new partition.
    – shgnInc
    Oct 25, 2015 at 4:44

After an automatic update to mysqld-5.5.53 ubuntu 14.04.1, mysql would not start. These lines showed up in my syslog:

Oct 27 06:05:51 hostname kernel: [  593.168925] init: mysql post-start process (4997) terminated with status 1
Oct 27 06:05:51 hostname kernel: [  593.178241] type=1400 audit(1477562751.231:31): apparmor="STATUS" operation="profile_replace" profile="unconfined" name
Oct 27 06:05:51 hostname kernel: [  593.204392] init: mysql main process (5032) terminated with status 1
Oct 27 06:05:51 hostname kernel: [  593.204404] init: mysql respawning too fast, stopped

The problem was solved by creating this directory:

sudo mkdir /var/lib/mysql-files
sudo chmod 700 /var/lib/mysql-files
sudo chown mysql:mysql /var/lib/mysql-files
sudo /etc/init.d/mysql start

Just updated MySQL and AppArmor version as suggested here to fix this problem on Ubuntu 12.04 running on Amazon ec2 instance. I still get the error a few time but MySQL restarts itself automatically.

  • 1
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Ringtail
    Nov 25, 2012 at 0:49

I had the same error messages, but the cause was different. My InnoDB tables were corrupt, because the whole file system went into read-only mode. I fixed the corruption by adding the following line to /etc/mysql/my.cf

innodb_force_recovery = 1

I started MySQL:

sudo service mysql start

MySQL did start and I dumped/exported all tables. I changed the innodb_force_recovery to 0 (=default) and restarted MySQL:

sudo service mysql restart

I'm using Ubuntu 12.04 with MySQL 5.5. It took a long time before I found the problem and I hope I can help someone with this answer. See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html


In my case the problem was the /etc/mysql/my.cnf file permission.

I changed it for cenvenience but it caused erros like

kernel: [604528.290448] type=1400 audit(1424350956.727:193): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="/usr/sbin/mysqld" pid=15008 comm="apparmor_parser"

The my.cnf permission was 766 and I changed it to 744 and two of three errors went away. There is still one similar error message but it did not prevent mysql from starting.

Hope this helps...


In my case, I had a wrong bind-address declaration. I ran ifconfig to discover the EC2's private IP address and updated it in the /etc/mysql/my.cnf file.


In my case i found a permission problem on /tmp. I just setted the tmp's directory permission to 766 and restart mysql service. Fixed out.

You must log in to answer this question.

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