Bug #91925 --add-drop-database incompatible with --users
Submitted: 8 Aug 2018 2:08 Modified: 8 Aug 2018 5:40
Reporter: liu shun Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: mysqlpump Command-line Client Severity:S3 (Non-critical)
Version:5.7.22. 5.7.23 OS:Any
Assigned to: CPU Architecture:Any

[8 Aug 2018 2:08] liu shun
Dump user accounts as logical definitions in the form of CREATE USER and GRANT statements.
User definitions are stored in the grant tables in the mysql system database. By default, mysqlpump does not include the grant tables in mysql database dumps.

Use mysqlpump with --add-drop-database and --users options,"DROP DATABASE IF EXISTS `mysql;`; " was added.
when importing the dumpfile ,mysql database will be dropped include grant tables,then then grant commands will be failed.

How to repeat:
1.dump all database .
time /apps/svr/mysql57/bin/mysqlpump -uroot -p'******' -S/tmp/mysql3306.sock -A --add-drop-database --exclude-databases=log  --add-drop-table --default-parallelism=4 --set-gtid-purged=on --single-transaction --users  --result-file=all_dump.sql --log-error-file=all_dump.log 
mysqlpump: [Warning] Using a password on the command line interface can be insecure.
real    1m10.806s
user    3m50.312s
sys     0m20.960s

2.import data
time  /apps/svr/mysql57/bin/mysql -uroot -p'*********' -S/tmp/mysql3307.sock  < all_dump.sql  
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1146 (42S02) at line 158757: Table 'mysql.user' doesn't exist
real    7m20.242s
user    1m20.157s
sys     0m3.353s

Suggested fix:
Add CREATE TABLE IF EXISTS ${grant tables} in the dump file.
[8 Aug 2018 2:11] liu shun
Sorry,i mean:
[8 Aug 2018 3:09] liu shun
I think it's better to skip `mysql` when --add-drop-database is used.
[8 Aug 2018 5:40] MySQL Verification Team
Hello liu shun,

Thank you for the report.
Observed this with 5.7.23.