MariaDB 10.1 server won't start when MySQL 5.7 server has been previously installed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apparmor (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
mariadb-10.1 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
mysql-5.7 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
If you purge MySQL 5.7 server, then install MariaDB 10.1, that last won't start due to wrong AppArmor profile.
CURRENT RESULT ON mariadb-server-10.1 package installation
...
Job for mariadb.service failed because a timeout was exceeded.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
...
# LANG=C systemctl status mariadb
* mariadb.service - MariaDB 10.1.34 database server
Loaded: loaded (/lib/systemd/
Active: failed (Result: timeout) since Sun 2018-12-02 17:26:09 UTC; 59s ago
Docs: man:mysqld(8)
https:/
Main PID: 23245 (code=exited, status=0/SUCCESS)
Dec 02 17:24:37 bionic systemd[1]: Starting MariaDB 10.1.34 database server...
Dec 02 17:24:37 bionic mysqld[23245]: 2018-12-02 17:24:37 139820621216896 [Note] /usr/sbin/mysqld (mysqld 10.1.34-
Dec 02 17:26:07 bionic systemd[1]: mariadb.service: Start operation timed out. Terminating.
Dec 02 17:26:09 bionic systemd[1]: mariadb.service: Failed with result 'timeout'.
Dec 02 17:26:09 bionic systemd[1]: Failed to start MariaDB 10.1.34 database server.
EXPECTED RESULT
MariaDB 10.1 server starting as expected.
HOWTO REPRODUCE
apt-get install mysql-server-5.7 mysql-client-5.7
apt-get purge mysql-server-5.7 mysql-client-5.7
apt-get install mariadb-server-10.1 mariadb-client-10.1
DISCUSSION
The mysql-server-5.7 package install an /etc/apparmor.
# dpkg -S /etc/apparmor.
mysql-server-5.7: /etc/apparmor.
When purging the mysql-server-5.7 server package get purged, the /etc/apparmor.
# aa-status | grep 'mysqld'
/usr/sbin/mysqld
This lead to MariaDB 1.0 server not being able to start due to MySQL 5.7 APPARMOR(7) profile that is still loaded.
Furthermore, the mariadb-server-10.1 also comes with an APPARMOR(7) profile which as per it header comments is "intensionally empty to disable apparmor by default for newer versions of MariaDB".
This is a big mistake as such a profile is simply wrong in regard of APPARMOR_PARSER(8) and as such, won't be unloaded:
# apparmor_parser -v -R /etc/apparmor.
# aa-status | grep 'mysqld'
/usr/sbin/mysqld
while:
# echo "/usr/sbin/mysqld { }" > /etc/apparmor.
# apparmor_parser -v -R /etc/apparmor.
Removal succeeded for "/usr/sbin/mysqld".
# aa-status | grep 'mysqld'
FIX PROPOSAL
1. When mysql-server-5.7 package is being removed/purged, the APPARMOR(7) profile should be unloaded and removed ranther than be simply removed.
2. The profile provided by the mariadb-server-10.1 package should have correct syntax in regard of APPARMOR_PARSER(8)
3. The mariadb-server-10.1 package postinst/postrm maintainer scripts should handle apparmor profile (load/unload)
Env Ubuntu Bionic Beaver (18.04)
Just hit this bug when trying to change from mysql to mariadb.
Solution: reboot after purging mysql and installing mariadb will load the correct AppArmor profile.