CREATETABLEIFNOTEXISTShost(Hostchar(60)binaryDEFAULT''NOTNULL,Dbchar(64)binaryDEFAULT''NOTNULL,Select_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Insert_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Update_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Delete_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Drop_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Grant_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,References_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Index_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Execute_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,PRIMARYKEYHost(Host,Db))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='Host privileges; Merged with database privileges';
CREATETABLEIFNOTEXISTShost(Hostchar(60)binaryDEFAULT''NOTNULL,Dbchar(64)binaryDEFAULT''NOTNULL,Select_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Insert_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Update_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Delete_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Drop_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Grant_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,References_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Index_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Execute_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,PRIMARYKEYHost(Host,Db))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='Host privileges; Merged with database privileges';
CREATETABLEIFNOTEXISTSuser(Hostchar(60)binaryDEFAULT''NOTNULL,Userchar(16)binaryDEFAULT''NOTNULL,Passwordchar(41)charactersetlatin1collatelatin1_binDEFAULT''NOTNULL,Select_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Insert_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Update_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Delete_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Drop_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Reload_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Shutdown_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Process_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,File_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Grant_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,References_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Index_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_db_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Super_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Execute_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Repl_slave_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Repl_client_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_user_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,ssl_typeenum('','ANY','X509','SPECIFIED')COLLATEutf8_general_ciDEFAULT''NOTNULL,ssl_cipherBLOBNOTNULL,x509_issuerBLOBNOTNULL,x509_subjectBLOBNOTNULL,max_questionsint(11)unsignedDEFAULT0NOTNULL,max_updatesint(11)unsignedDEFAULT0NOTNULL,max_connectionsint(11)unsignedDEFAULT0NOTNULL,max_user_connectionsint(11)unsignedDEFAULT0NOTNULL,PRIMARYKEYHost(Host,User))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='Users and global privileges';
CREATETABLEIFNOTEXISTSuser(Hostchar(60)binaryDEFAULT''NOTNULL,Userchar(16)binaryDEFAULT''NOTNULL,Passwordchar(41)charactersetlatin1collatelatin1_binDEFAULT''NOTNULL,Select_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Insert_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Update_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Delete_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Drop_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Reload_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Shutdown_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Process_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,File_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Grant_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,References_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Index_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_db_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Super_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Execute_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Repl_slave_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Repl_client_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Show_view_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Alter_routine_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,Create_user_privenum('N','Y')COLLATEutf8_general_ciDEFAULT'N'NOTNULL,ssl_typeenum('','ANY','X509','SPECIFIED')COLLATEutf8_general_ciDEFAULT''NOTNULL,ssl_cipherBLOBNOTNULL,x509_issuerBLOBNOTNULL,x509_subjectBLOBNOTNULL,max_questionsint(11)unsignedDEFAULT0NOTNULL,max_updatesint(11)unsignedDEFAULT0NOTNULL,max_connectionsint(11)unsignedDEFAULT0NOTNULL,max_user_connectionsint(11)unsignedDEFAULT0NOTNULL,PRIMARYKEYHost(Host,User))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='Users and global privileges';
-- Remember for later if user table already existed
set@had_user_table=@@warning_count!=0;
CREATETABLEIFNOTEXISTSfunc(namechar(64)binaryDEFAULT''NOTNULL,rettinyint(1)DEFAULT'0'NOTNULL,dlchar(128)DEFAULT''NOTNULL,typeenum('function','aggregate')COLLATEutf8_general_ciNOTNULL,PRIMARYKEY(name))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='User defined functions';
CREATETABLEIFNOTEXISTSfunc(namechar(64)binaryDEFAULT''NOTNULL,rettinyint(1)DEFAULT'0'NOTNULL,dlchar(128)DEFAULT''NOTNULL,typeenum('function','aggregate')COLLATEutf8_general_ciNOTNULL,PRIMARYKEY(name))engine=MyISAMCHARACTERSETutf8COLLATEutf8_bincomment='User defined functions';