#-- Detect whether or not we had the Grant_priv column
print"Fixing privileges for old tables...\n";
$conn->query("SET \@hadGrantPriv:=0;");
$conn->query("SELECT \@hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';");
#--- Fix privileges for old tables
$conn->query("UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE \@hadGrantPriv = 0;");
$conn->query("UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE \@hadGrantPriv = 0;");
$conn->query("UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE \@hadGrantPriv = 0;");
# Detect whether we had Show_db_priv
$conn->query("SET \@hadShowDbPriv:=0;");
$conn->query("SELECT \@hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';");
print"Adding new fields used by MySQL 4.0.2 to the privilege tables...\n";
print"NOTE: You can ignore any Duplicate column errors.\n";
$conn->query("\
...
...
@@ -81,9 +96,11 @@ ADD Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv, \
ADD Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv, \
ADD Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; \
")&&$conn->query("\
UPDATE user SET show_db_priv=select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>''; \
UPDATE user SET show_db_priv=select_priv, super_priv=process_priv, execute_priv=process_priv, create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=file_priv where user<>''AND \@hadShowDbPriv = 0; \
");
#-- The above statement converts privileges so that users have similar privileges as before
@@ -10,7 +10,7 @@ INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y',
CREATETABLEhost(Hostchar(60)binaryDEFAULT''NOTNULL,Dbchar(64)binaryDEFAULT''NOTNULL,Select_privenum('N','Y')DEFAULT'N'NOTNULL,Insert_privenum('N','Y')DEFAULT'N'NOTNULL,Update_privenum('N','Y')DEFAULT'N'NOTNULL,Delete_privenum('N','Y')DEFAULT'N'NOTNULL,Create_privenum('N','Y')DEFAULT'N'NOTNULL,Drop_privenum('N','Y')DEFAULT'N'NOTNULL,Grant_privenum('N','Y')DEFAULT'N'NOTNULL,References_privenum('N','Y')DEFAULT'N'NOTNULL,Index_privenum('N','Y')DEFAULT'N'NOTNULL,Alter_privenum('N','Y')DEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')DEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')DEFAULT'N'NOTNULL,PRIMARYKEYHost(Host,Db))comment='Host privileges; Merged with database privileges';
CREATETABLEuser(Hostchar(60)binaryDEFAULT''NOTNULL,Userchar(16)binaryDEFAULT''NOTNULL,Passwordchar(45)binaryDEFAULT''NOTNULL,Select_privenum('N','Y')DEFAULT'N'NOTNULL,Insert_privenum('N','Y')DEFAULT'N'NOTNULL,Update_privenum('N','Y')DEFAULT'N'NOTNULL,Delete_privenum('N','Y')DEFAULT'N'NOTNULL,Create_privenum('N','Y')DEFAULT'N'NOTNULL,Drop_privenum('N','Y')DEFAULT'N'NOTNULL,Reload_privenum('N','Y')DEFAULT'N'NOTNULL,Shutdown_privenum('N','Y')DEFAULT'N'NOTNULL,Process_privenum('N','Y')DEFAULT'N'NOTNULL,File_privenum('N','Y')DEFAULT'N'NOTNULL,Grant_privenum('N','Y')DEFAULT'N'NOTNULL,References_privenum('N','Y')DEFAULT'N'NOTNULL,Index_privenum('N','Y')DEFAULT'N'NOTNULL,Alter_privenum('N','Y')DEFAULT'N'NOTNULL,Show_db_privenum('N','Y')DEFAULT'N'NOTNULL,Super_privenum('N','Y')DEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')DEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')DEFAULT'N'NOTNULL,Execute_privenum('N','Y')DEFAULT'N'NOTNULL,Repl_slave_privenum('N','Y')DEFAULT'N'NOTNULL,Repl_client_privenum('N','Y')DEFAULT'N'NOTNULL,ssl_typeenum('','ANY','X509','SPECIFIED')DEFAULT''NOTNULL,ssl_cipherBLOBNOTNULL,x509_issuerBLOBNOTNULL,x509_subjectBLOBNOTNULL,max_questionsint(11)unsignedDEFAULT0NOTNULL,max_updatesint(11)unsignedDEFAULT0NOTNULL,max_connectionsint(11)unsignedDEFAULT0NOTNULL,PRIMARYKEYHost(Host,User))comment='Users and global privileges';
CREATETABLEuser(Hostchar(60)binaryDEFAULT''NOTNULL,Userchar(16)binaryDEFAULT''NOTNULL,Passwordchar(41)binaryDEFAULT''NOTNULL,Select_privenum('N','Y')DEFAULT'N'NOTNULL,Insert_privenum('N','Y')DEFAULT'N'NOTNULL,Update_privenum('N','Y')DEFAULT'N'NOTNULL,Delete_privenum('N','Y')DEFAULT'N'NOTNULL,Create_privenum('N','Y')DEFAULT'N'NOTNULL,Drop_privenum('N','Y')DEFAULT'N'NOTNULL,Reload_privenum('N','Y')DEFAULT'N'NOTNULL,Shutdown_privenum('N','Y')DEFAULT'N'NOTNULL,Process_privenum('N','Y')DEFAULT'N'NOTNULL,File_privenum('N','Y')DEFAULT'N'NOTNULL,Grant_privenum('N','Y')DEFAULT'N'NOTNULL,References_privenum('N','Y')DEFAULT'N'NOTNULL,Index_privenum('N','Y')DEFAULT'N'NOTNULL,Alter_privenum('N','Y')DEFAULT'N'NOTNULL,Show_db_privenum('N','Y')DEFAULT'N'NOTNULL,Super_privenum('N','Y')DEFAULT'N'NOTNULL,Create_tmp_table_privenum('N','Y')DEFAULT'N'NOTNULL,Lock_tables_privenum('N','Y')DEFAULT'N'NOTNULL,Execute_privenum('N','Y')DEFAULT'N'NOTNULL,Repl_slave_privenum('N','Y')DEFAULT'N'NOTNULL,Repl_client_privenum('N','Y')DEFAULT'N'NOTNULL,ssl_typeenum('','ANY','X509','SPECIFIED')DEFAULT''NOTNULL,ssl_cipherBLOBNOTNULL,x509_issuerBLOBNOTNULL,x509_subjectBLOBNOTNULL,max_questionsint(11)unsignedDEFAULT0NOTNULL,max_updatesint(11)unsignedDEFAULT0NOTNULL,max_connectionsint(11)unsignedDEFAULT0NOTNULL,PRIMARYKEYHost(Host,User))comment='Users and global privileges';
@@ -20,7 +20,7 @@ INSERT INTO user (host,user) values ('','');
CREATETABLEfunc(namechar(64)binaryDEFAULT''NOTNULL,rettinyint(1)DEFAULT'0'NOTNULL,dlchar(128)DEFAULT''NOTNULL,typeenum('function','aggregate')NOTNULL,PRIMARYKEY(name))comment='User defined functions';