mysql-server-5.7.postinst fails with "Can't create database 'performance_schema'; database exists"

Bug #1574168 reported by Martin Sommer
80
This bug affects 16 people
Affects Status Importance Assigned to Milestone
mysql-5.7 (Ubuntu)
Triaged
High
Lars Tangvald

Bug Description

upgrade to 16.04

ProblemType: Package
DistroRelease: Ubuntu 16.04
Package: mysql-server 5.7.11-0ubuntu6
ProcVersionSignature: Ubuntu 4.4.0-21.37-generic 4.4.6
Uname: Linux 4.4.0-21-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
Date: Sat Apr 23 18:02:29 2016
ErrorMessage: dependency problems - leaving unconfigured
InstallationDate: Installed on 2014-05-12 (712 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
Logs.var.log.daemon.log:

MySQLConf.etc.mysql.conf.d.mysql.cnf: [mysql]
MySQLConf.etc.mysql.conf.d.mysqld_safe_syslog.cnf:
 [mysqld_safe]
 syslog
MySQLConf.etc.mysql.conf.d.mysqldump.cnf:
 [mysqldump]
 quick
 quote-names
 max_allowed_packet = 16M
MySQLConf.etc.mysql.mysql.conf.d.mysqld_safe_syslog.cnf:
 [mysqld_safe]
 syslog
MySQLVarLibDirListing: ['ib_logfile0', 'Joomla_SQL', 'ibtmp1', 'auto.cnf', 'mysql_upgrade_info', 'mysql', 'ibdata1', 'sugarcrm', 'Test', 'debian-5.5.flag', 'piwigo', 'Phraseanet_Databox', 'sys', 'debian-5.7.flag', 'drupal', 'performance_schema', 'Phraseanet_Application_Box', 'ib_logfile1']
PackageArchitecture: all
ProcCmdline: BOOT_IMAGE=/boot/vmlinuz-4.4.0-21-generic root=UUID=03aece80-e9cb-4989-be01-16da75b29d4a ro quiet splash vt.handoff=7
RelatedPackageVersions:
 dpkg 1.18.4ubuntu1
 apt 1.2.10ubuntu1
SourcePackage: mysql-5.7
Title: package mysql-server 5.7.11-0ubuntu6 failed to install/upgrade: dependency problems - leaving unconfigured
UpgradeStatus: Upgraded to xenial on 2016-04-23 (0 days ago)

Revision history for this message
Martin Sommer (architekt-sommer) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mysql-5.7 (Ubuntu):
status: New → Confirmed
Revision history for this message
Robie Basak (racb) wrote :

From log:

Setting up mysql-server-5.7 (5.7.11-0ubuntu6) ...
Installing new version of config file /etc/apparmor.d/usr.sbin.mysqld ...
Installing new version of config file /etc/init.d/mysql ...
Installing new version of config file /etc/init/mysql.conf ...
Installing new version of config file /etc/logrotate.d/mysql-server ...
Installing new version of config file /etc/mysql/debian-start ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
insserv: warning: script 'K01nuclos.nuclos' missing LSB tags and overrides
insserv: warning: script 'K01postgresql-9.3' missing LSB tags and overrides
insserv: warning: script 'nuclos.nuclos' missing LSB tags and overrides
insserv: warning: script 'postgresql-9.3' missing LSB tags and overrides
mysql start/running, process 17027
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
mysql_upgrade: [ERROR] 1007: Can't create database 'performance_schema'; database exists
mysql_upgrade failed with exit status 5
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured

summary: - package mysql-server 5.7.11-0ubuntu6 failed to install/upgrade:
- dependency problems - leaving unconfigured
+ mysql-server-5.7.postinst fails with "Can't create database
+ 'performance_schema'; database exists"
Changed in mysql-5.7 (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → High
Revision history for this message
Vertago1 (vertago1) wrote :

I ran into a problem upgrading mysql-server-5.7 and the issue was I had at some point disabled mysql by default with "sudo systemctl disable mysql.service". I have it installed so I can run it when I need it. To get the upgrade to work I had to:

sudo systemctl enable mysql.service
sudo apt-get install mysql-server-5.7
sudo systemctl disable mysql.service

This worked for me.

Robie Basak (racb)
Changed in mysql-5.7 (Ubuntu):
assignee: nobody → Lars Tangvald (lars-tangvald)
milestone: none → ubuntu-16.05
Revision history for this message
rammstein (doyen-gilles) wrote :

What worked for me (on all the tested scenarios) is to:
sudo apt-get remove --purge mysql*
sudo apt-get install mysql-server

(this will also flush the client and I think it's actually him the root cause of the issue)

After this, mysql works like a charm on my machines

Revision history for this message
Bob Jones (r-a-n-d-o-m-d-e-v-4+ubuntu) wrote :

Also affects me, I've tried *everything* listed above, purging etc. and nothing works (even after rm'ing config and other old files)

Poor QA by the repo team, very poor. ;-(

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"

Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

Did you also see the specific error message "Can't create database 'performance_schema'; database exists" ?

We saw this when upgrading from Ubuntu 14.04 to 16.04 due to a race condition between the new postinst and old upstart script (which would still be running until the host is rebooted and switched to systemd).

This was fixed as per https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1577712 (not yet released), but if you're still seeing the same issue after a reboot then it might be a separate problem.

Revision history for this message
Bob Jones (r-a-n-d-o-m-d-e-v-4+ubuntu) wrote :

Mine isn't even a 14->16 upgrade. Its a 16LTS based "apt-get upgrade" of a pre-existing install (or at least it was an attempt at that ...I can't get the darn thing to install itself no matter how I try, as I said, I've tried resorting to removing/purging/deleting confs ... nothing works)

Revision history for this message
Bob Jones (r-a-n-d-o-m-d-e-v-4+ubuntu) wrote :
Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

Thanks for the log:
Jul 06 13:41:59 ops-bk01 mysql-systemd-start[25625]: MySQL system database not found. Please run mysql_install

The systemd script checks that /var/lib/mysql exists, and that it has a /var/lib/mysql/mysql database in it. The first check seems to pass, but the second causes the above error.

The issue might be that the systemd script is too dependent on a default setup. What do the contents of your /var/lib/mysql look like?

Revision history for this message
Bob Jones (r-a-n-d-o-m-d-e-v-4+ubuntu) wrote :

$ sudo ls -l /var/lib/mysql
total 0
-rw-r--r-- 1 mysql mysql 0 Jul 6 13:41 debian-5.7.flag

Revision history for this message
Lars Tangvald (lars-tangvald) wrote :

Yeah, that flag file is there to guard against downgrades, but causes as many issues as it fixes, so we're working on finding another solution.

My suggestion is to «rm -rf /var/lib/mysql», then run «apt-get -f install» to reconfigure the package.
Hopefully that's the only problem and this will fix it.

Revision history for this message
Chris (cnizzardini) wrote :

Repost from duplicate bug thread: Also receiving this error. A ton of errors really. It also failed to update several MySQL tables in information_schema and performance_schema and many other things. Over a series of hours I got MySQL to work by running mysql_upgrade and doing several other things, some of which are linked to below, sorry I did not create exact steps:

http://askubuntu.com/questions/705458/ubuntu-15-10-mysql-error-1524-unix-socket
http://stackoverflow.com/questions/31967527/table-performance-schema-session-variables-doesnt-exist

Finally I noticed this:
Setting up mysql-server-5.7 (5.7.12-0ubuntu1.1) ...
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server

SOLUTION:
CREATE USER 'debian-sys-maint'@'localhost' IDENTIFIED BY '***';GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '***' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

Note: You can get the debian-sys-maint password from /etc/mysql/debian.cnf

Then: sudo apt-get upgrade

Anyways good luck folks, this took me several hours to move through this hell. I believe something messed up with the install, the debian-sys-maint user was not created, so system could not update MySQL schema which probably lead to a whole host of other errors. Be sure to check your logs so you can resolve this quicker than it took me.

Revision history for this message
Bob Jones (r-a-n-d-o-m-d-e-v-4+ubuntu) wrote :

Just after I wasted time earlier this month re-installing all my mySQL because of the above problem, another update comes through today (5.7.13-0ubuntu0.16.04.2), and guess what, that breaks it too.

Thanks Ubuntu... just thanks. Your QA is sloppy. Two important packages, NTP and mySQL are currently broken on ubuntu because of sloppy QA causing them to break after an apt-get upgrade.

At this rate I'm going to start rolling out another distro and dump Ubuntu.

Revision history for this message
Robie Basak (racb) wrote :

I believe that the root cause of this bug was actually bug 1577712 that we fixed in June (Yakkety) and July (Xenial, 16.04), so am marking this bug as a duplicate of that one. See bug 1577712 for details.

For others subscribed to this bug, or otherwise believe they're affected by this issue: I see many comments above that I think are clearly due to unrelated issues, so this bug is probably not the one you want.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.