Can't start mysql - mysql respawning too fast, stopped

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...


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

with:

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

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


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.


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:

 --master-host
 --master-user
 --master-password
 --master-port
 --master-connect-retry
 --master-ssl
 --master-ssl-ca
 --master-ssl-capath
 --master-ssl-cert
 --master-ssl-cipher
 --master-ssl-key