Bug #76313 getting error with mysql_upgrade
Submitted: 13 Mar 2015 12:43 Modified: 14 Aug 2015 13:17
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Installing Severity:S2 (Serious)
Version:5.7.6 OS:Windows (7/64)
Assigned to: CPU Architecture:Any

[13 Mar 2015 12:43] Peter Laursen
Description:
Getting an error in the console when running mysql_upgrade after upgrade from 5.7.5 to 5.7.6 (using "Windows Installer").

How to repeat:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql_upgrade -P3311 -uroot -p
Enter password: ********
Checking if update is needed.
Checking server version.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running queries to upgrade MySQL server.
Checking databases.
Failed to run query "ALTER DATABASE `#mysql50#-1` UPGRADE DATA DIRECTORY NAME"
Error: Can't create database '-1'; database exists
#mysql50#-1                                        FAILED
Upgrade process completed successfully.
Checking if update is needed.

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -P3311 -uroot -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.6-m16-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
+---------------+
| version()     |
+---------------+
| 5.7.6-m16-log |
+---------------+
1 row in set (0.00 sec)

mysql>

Suggested fix:
I don't kno what tis

Failed to run query "ALTER DATABASE `#mysql50#-1` UPGRADE DATA DIRECTORY NAME"
Error: Can't create database '-1'; database exists
#mysql50#-1                                        FAILED

.. actually means, and if I safely can ignore it. I think 5.7.6 had added new PS tables (as I understand some blogging from the developer team), so a major reason to run mysql_upgrade in this case would be to enable those new P_S tables. 

I a uncertain about the category for this report.  You can change as appropriate.

(and there are no databases named `-1` nor `#mysql50#-1` on this server, of course)
[13 Mar 2015 12:44] Peter Laursen
Corrected version.
[13 Mar 2015 13:04] MySQL Verification Team
See http://bugs.mysql.com/bug.php?id=76262 InnoDB stuff involved.
[13 Mar 2015 13:28] Peter Laursen
I found this on the web: 
https://ma.ttias.be/mysql-upgrade-to-5-1-database-name-prefix-mysql50/

.. but this database has never been anything else than 5.7x (not upgraded from a previos version). I did a fresh install of an early 5.7.x when I had my current work computer in June 2014. This instance has been upgraded with every 5.7x version released since.
[25 Mar 2015 14:51] Peter Laursen
This "(and there are no databases named `-1` nor `#mysql50#-1` on this server, of course)"

..   is not correct anymore.  The two weird databaes exist now (after msyql_upgrade). They are both empty - no tables or any other kind of object in them.

Should I try to drop then and run "mysql_upgrade --force" and see what happens? If it is useful for you, I can do.  If not, I'll simply drop them.
[14 Aug 2015 12:48] Chiranjeevi Battula
Hello Peter,

Thank you for the bug report.
I tried with latest MySQL Installer, and attempted to upgrade from 5.7.5 to 5.7.6 and run mysql_upgrade at administrative command prompt and it worked without any issues. 
Probably this is fixed, please feel free to reopen this bug report if you encounter this issue again.

Thanks,
Chiranjeevi.
[14 Aug 2015 12:49] Chiranjeevi Battula
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\windows\system32>cd \

C:\>cd C:\Program Files\MySQL\MySQL Server 5.7\bin

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql_upgrade -uroot -p
Enter password: ******
Checking if update is needed.
Checking server version.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running queries to upgrade MySQL server.
Checking databases.
Upgrade process completed successfully.
Checking if update is needed.

C:\Program Files\MySQL\MySQL Server 5.7\bin>
[14 Aug 2015 13:17] Peter Laursen
Well, I don't have the environment anymore.  I did let the Installer upgrade from 5.7.7 to 5.7.8 last week (or earlier this week, maybe) and I think the Installer now hsa an option to run mysql_upgrade after a server upgrade. Now it is not reproducible:

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql_upgrade -P3311 -uroot -p
Enter password: ********
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.8-rc, use --force if you still need to run mysql_upgrade

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql_upgrade --force -P3311 -uroot -p
Enter password: ********
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
The sys schema is already up to date (version 1.4.0).
Checking databases.
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.

C:\Program Files\MySQL\MySQL Server 5.7\bin>

.. and on a side-remark, I think 4 months is way-too-much-time for checking and replying to a report of this kind.