3

After following the instructions in this post on how to install MySQL 5.6 over an existing 5.7 installation on Ubuntu 16.04 I had multiple problems starting the service.

First this happened:

Failed to start mysql.service: Unit mysql.service is masked

Which was solved by running systemctl unmask mysql.service. However then I repeatedly had this message:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

Inspecting systemctl status mysql.service showed:

Failed to start LSB: Start and stop the mysql database server daemon.
10

After Downgrading MySQL version I am also facing this try following command

systemctl unmask mysql.service
service mysql start
| improve this answer | |
2

The fix for this contained multiple steps including different debug logs and then following clues in those logs. I'm documenting them to help others - your problems might be different but this process should help to discover what's wrong:

Firstly journalctl -xe contains a lot more information. In my case it contained:

kernel: audit: type=1400 audit(1528794958.103:169): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/my.cnf.fallback"

This could be fixed with vi /etc/apparmor.d/usr.sbin.mysqld and adding lines for:

/etc/mysql/conf.d/mysql.cnf/ r,
/etc/mysql/conf.d/mysql.cnf/* r,
/etc/mysql/my.cnf.fallback r,

An interesting point is that it needs a separate line for a directory and wildcard files within it - this can be common for some unix applications but not all so might trip you up.

Once all the apparmor changes were done the system still wouldn't start, and this time the journalctl -xe command yielded nothing useful.

I was then able to run sudo -u mysql mysqld to try starting the daemon manually. This showed a failure with InnoDB starting up, but not why.

On a whim I deleted the files /var/lib/mysql/ib_logfile* and ib_binlog and tried again; this time the server started. I was then able to terminate this and run service start mysql which worked.

Separately I deleted /var/lib/mysql/debian-5.7.flag - I am unsure if this helped or would have caused subsequent problems if I had not done so.

Hopefully this example helps somebody; please feel free to add other answers along a similar line if you encountered different problems with this process.

| improve this answer | |
  • 1
    Indeed apparmor can be sometimes hasle :) – Alpy Mar 2 '19 at 8:40
  • i completely purged apparmor, and this still happens! – thang Mar 16 '19 at 19:35
  • @thang as in you still get apparmor denied errors? It's likely apparmor still contains some references to SQL as part of a default config maybe? Try completely disabling it (temporarily) and seeing the the errors persist - if they do there's something odd going on with your system! – M1ke Mar 21 '19 at 12:15
  • i got it going. i had to uninstall mysql and reinstall it, then manually remove everything apparmor related in /etc and /usr. i don't know how much of that is necessary, but that works. – thang Mar 22 '19 at 16:28
0

First stop mysql, if it is running

BACKUP=/var/tmp/broken-mysql
sudo mkdir -p $BACKUP               # create backup dir
sudo mv -vi /var/lib/mysql* $BACKUP # Remove any old database setup
sudo mysql_install_db -u mysql      # Install new database
sudo systemctl unmask mysql.service # Enables the service for systemd
sudo service mysql start            # Start the service
| improve this answer | |
  • 1
    This is really dangerous!! I edited, so you don't delete all your data in the first place. But still, this doesn't seem to work on Ubuntu 18.10 – rubo77 Mar 2 '19 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.