diff options
Diffstat (limited to 'scripts/mysql_fix_privilege_tables.sql')
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index aea44e84fef..3c82a0164c8 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -1,13 +1,13 @@ --- This script converts any old privilege tables to privilege tables suitable --- for this version of MySQL +# This script converts any old privilege tables to privilege tables suitable +# for this version of MySQL --- You can safely ignore all 'Duplicate column' and 'Unknown column' errors" --- because these just mean that your tables are already up to date. --- This script is safe to run even if your tables are already up to date! +# You can safely ignore all 'Duplicate column' and 'Unknown column' errors" +# because these just mean that your tables are already up to date. +# This script is safe to run even if your tables are already up to date! --- On unix, you should use the mysql_fix_privilege_tables script to execute --- this sql script. --- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' +# On unix, you should use the mysql_fix_privilege_tables script to execute +# this sql script. +# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' set storage_engine=MyISAM; @@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS plugin ( ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; --- Detect whether or not we had the Grant_priv column +# Detect whether or not we had the Grant_priv column SET @hadGrantPriv:=0; SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%'; @@ -35,14 +35,14 @@ ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,a ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; --- Fix privileges for old tables +# Fix privileges for old tables UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; --- --- The second alter changes ssl_type to new 4.0.2 format --- Adding columns needed by GRANT .. REQUIRE (openssl)" +# +# The second alter changes ssl_type to new 4.0.2 format +# Adding columns needed by GRANT .. REQUIRE (openssl)" ALTER TABLE user ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL, @@ -51,9 +51,9 @@ ADD x509_issuer BLOB NOT NULL, ADD x509_subject BLOB NOT NULL; ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; --- --- Create tables_priv and columns_priv if they don't exists --- +# +# Create tables_priv and columns_priv if they don't exists +# CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, @@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS tables_priv ( Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields +# Fix collation of set fields ALTER TABLE tables_priv modify Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, modify Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; @@ -88,26 +88,26 @@ CREATE TABLE IF NOT EXISTS columns_priv ( Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields +# Fix collation of set fields ALTER TABLE columns_priv MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; --- --- Name change of Type -> Column_priv from MySQL 3.22.12 --- +# +# Name change of Type -> Column_priv from MySQL 3.22.12 +# ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; --- --- Add the new 'type' column to the func table. --- +# +# Add the new 'type' column to the func table. +# ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; --- --- Change the user,db and host tables to MySQL 4.0 format --- +# +# Change the user,db and host tables to MySQL 4.0 format +# # Detect whether we had Show_db_priv SET @hadShowDbPriv:=0; @@ -122,22 +122,22 @@ ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTE ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv, ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; --- Convert privileges so that users have similar privileges as before +# Convert privileges so that users have similar privileges as before 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; --- Add fields that can be used to limit number of questions and connections --- for some users. +# Add fields that can be used to limit number of questions and connections +# for some users. ALTER TABLE user ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject, ADD max_updates int(11) unsigned NOT NULL DEFAULT 0 AFTER max_questions, ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates; --- --- Add Create_tmp_table_priv and Lock_tables_priv to db and host --- +# +# Add Create_tmp_table_priv and Lock_tables_priv to db and host +# ALTER TABLE db ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, @@ -156,8 +156,8 @@ alter table func comment='User defined functions'; alter table tables_priv comment='Table privileges'; alter table columns_priv comment='Column privileges'; --- Convert all tables to UTF-8 with binary collation --- and reset all char columns to correct width +# Convert all tables to UTF-8 with binary collation +# and reset all char columns to correct width ALTER TABLE user MODIFY Host char(60) NOT NULL default '', MODIFY User char(16) NOT NULL default '', @@ -412,7 +412,7 @@ Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) CHARACTER SET utf8 comment='Time zones'; --- Make enum field case-insensitive +# Make enum field case-insensitive ALTER TABLE time_zone MODIFY Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; @@ -554,9 +554,9 @@ ALTER TABLE proc MODIFY db MODIFY comment char(64) collate utf8_bin DEFAULT '' NOT NULL; --- --- Create missing log tables (5.1) --- +# +# Create missing log tables (5.1) +# delimiter // CREATE PROCEDURE create_log_tables() @@ -704,9 +704,9 @@ ALTER TABLE event ADD sql_mode UPDATE user SET Event_priv=Super_priv WHERE @hadEventPriv = 0; ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default ''; --- --- TRIGGER privilege --- +# +# TRIGGER privilege +# SET @hadTriggerPriv := 0; SELECT @hadTriggerPriv :=1 FROM user WHERE Trigger_priv LIKE '%'; @@ -724,6 +724,8 @@ ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; +CREATE TABLE IF NOT EXISTS binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; + # Activate the new, possible modified privilege tables # This should not be needed, but gives us some extra testing that the above # changes was correct |