1-- source include/not_embedded.inc
2
3# Dump all databases
4--exec $MYSQL_DUMP -uroot --all-databases > $MYSQLTEST_VARDIR/tmp/bug20902791.sql
5
6# Save a copy of the user/tables_priv, to restore later
7# Otherwise the final mysql_upgrade will REPLACE and update timestamps etc.
8CREATE TEMPORARY TABLE tmp_user AS SELECT * FROM mysql.user;
9CREATE TEMPORARY TABLE tmp_tables_priv AS SELECT * FROM mysql.tables_priv;
10
11# Remove the sys schema
12DROP DATABASE sys;
13
14# Reload the dump
15--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20902791.sql
16
17# The sys schema should not exist
18SHOW DATABASES;
19
20# Finally reload the sys schema to return to normal
21--exec $MYSQL_UPGRADE --skip-verbose --force
22SHOW DATABASES;
23
24# Restore the saved privileges
25TRUNCATE TABLE mysql.user;
26INSERT INTO mysql.user (SELECT * FROM tmp_user);
27DROP TEMPORARY TABLE tmp_user;
28
29TRUNCATE TABLE mysql.tables_priv;
30INSERT INTO mysql.tables_priv (SELECT * FROM tmp_tables_priv);
31DROP TEMPORARY TABLE tmp_tables_priv;
32
33FLUSH PRIVILEGES;
34