@@ -447,37 +447,44 @@ def bootstrap(self):
447
447
extra_sql = [
448
448
"CREATE DATABASE myconnpy;"
449
449
]
450
-
451
- if self ._version [0 :3 ] >= (5 , 7 , 5 ):
452
- # MySQL 5.7.5 creates no user while bootstrapping
453
- extra_sql .append (
454
- "INSERT INTO mysql.user VALUES ('localhost','root','',"
455
- "'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
456
- "'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
457
- "'Y','Y','Y','Y','Y','','','','',0,0,0,0,"
458
- "@@default_authentication_plugin,'','N',"
459
- "CURRENT_TIMESTAMP,NULL);"
460
- )
461
- if self ._version [0 :3 ] >= (5 , 7 , 4 ):
462
- # MySQL 5.7.4 only creates root@localhost
463
- extra_sql .append (
464
- "INSERT INTO mysql.user SELECT '127.0.0.1', `User`, `Password`,"
465
- " `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`,"
466
- " `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`,"
467
- " `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`,"
468
- " `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`,"
469
- " `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`,"
470
- " `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`,"
471
- " `Show_view_priv`, `Create_routine_priv`, "
472
- "`Alter_routine_priv`,"
473
- " `Create_user_priv`, `Event_priv`, `Trigger_priv`, "
474
- "`Create_tablespace_priv`, `ssl_type`, `ssl_cipher`,"
475
- "`x509_issuer`, `x509_subject`, `max_questions`, `max_updates`,"
476
- "`max_connections`, `max_user_connections`, `plugin`,"
477
- "`authentication_string`, `password_expired`,"
478
- "`password_last_changed`, `password_lifetime` FROM mysql.user "
479
- "WHERE `user` = 'root' and `host` = 'localhost';"
480
- )
450
+ insert = (
451
+ "INSERT INTO mysql.user VALUES ('localhost','root'{0},"
452
+ "'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
453
+ "'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',"
454
+ "'Y','Y','Y','Y','Y','','','','',0,0,0,0,"
455
+ "@@default_authentication_plugin,'','N',"
456
+ "CURRENT_TIMESTAMP,NULL{1});"
457
+ )
458
+ # MySQL 5.7.5+ creates no user while bootstrapping
459
+ if self ._version [0 :3 ] >= (5 , 7 , 6 ):
460
+ # MySQL 5.7.6+ have extra account_locked col and no password col
461
+ extra_sql .append (insert .format ("" , ",'N'" ))
462
+ elif self ._version [0 :3 ] >= (5 , 7 , 5 ):
463
+ extra_sql .append (insert .format (",''" , "" ))
464
+
465
+ insert_localhost = (
466
+ "INSERT INTO mysql.user SELECT '127.0.0.1', `User`{0},"
467
+ " `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`,"
468
+ " `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`,"
469
+ " `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`,"
470
+ " `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`,"
471
+ " `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`,"
472
+ " `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`,"
473
+ " `Show_view_priv`, `Create_routine_priv`, "
474
+ "`Alter_routine_priv`,"
475
+ " `Create_user_priv`, `Event_priv`, `Trigger_priv`, "
476
+ "`Create_tablespace_priv`, `ssl_type`, `ssl_cipher`,"
477
+ "`x509_issuer`, `x509_subject`, `max_questions`, `max_updates`,"
478
+ "`max_connections`, `max_user_connections`, `plugin`,"
479
+ "`authentication_string`, `password_expired`,"
480
+ "`password_last_changed`, `password_lifetime`{1} FROM mysql.user "
481
+ "WHERE `user` = 'root' and `host` = 'localhost';"
482
+ )
483
+ # MySQL 5.7.4+ only creates root@localhost
484
+ if self ._version [0 :3 ] >= (5 , 7 , 6 ):
485
+ extra_sql .append (insert_localhost .format ("" , ",`account_locked`" ))
486
+ elif self ._version [0 :3 ] >= (5 , 7 , 4 ):
487
+ extra_sql .append (insert_localhost .format (",`Password`" , "" ))
481
488
482
489
bootstrap_log = os .path .join (self ._topdir , 'bootstrap.log' )
483
490
try :
0 commit comments