2007-02-26 11:49:24 +01:00
|
|
|
# This part converts any old privilege tables to privilege tables suitable
|
|
|
|
# for current version of MySQL
|
2003-08-27 21:30:50 +02:00
|
|
|
|
2007-02-26 14:48:41 +01:00
|
|
|
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors
|
2007-02-26 11:49:24 +01:00
|
|
|
# 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!
|
2003-08-27 21:30:50 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# 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'
|
2003-08-27 21:30:50 +02:00
|
|
|
|
2007-05-19 18:15:08 +02:00
|
|
|
set sql_mode='';
|
2005-04-18 23:01:18 +02:00
|
|
|
set storage_engine=MyISAM;
|
2005-04-16 03:12:30 +02:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Detect whether or not we had the Grant_priv column
|
2003-06-04 17:28:51 +02:00
|
|
|
SET @hadGrantPriv:=0;
|
|
|
|
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
|
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE user 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;
|
|
|
|
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;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Fix privileges for old tables
|
2003-06-04 17:28:51 +02:00
|
|
|
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;
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# The second alter changes ssl_type to new 4.0.2 format
|
2007-02-26 14:49:41 +01:00
|
|
|
# Adding columns needed by GRANT .. REQUIRE (openssl)
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
ALTER TABLE user
|
2005-02-11 05:25:14 +01:00
|
|
|
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
|
2003-06-04 17:28:51 +02:00
|
|
|
ADD ssl_cipher BLOB NOT NULL,
|
|
|
|
ADD x509_issuer BLOB NOT NULL,
|
|
|
|
ADD x509_subject BLOB NOT NULL;
|
|
|
|
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# tables_priv
|
|
|
|
#
|
2006-11-29 12:04:29 +01:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE tables_priv
|
2006-11-29 12:04:29 +01:00
|
|
|
ADD KEY Grantor (Grantor);
|
|
|
|
|
|
|
|
ALTER TABLE tables_priv
|
|
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
|
|
MODIFY User char(16) NOT NULL default '',
|
|
|
|
MODIFY Table_name char(64) NOT NULL default '',
|
|
|
|
MODIFY Grantor char(77) NOT NULL default '',
|
|
|
|
ENGINE=MyISAM,
|
|
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2006-11-29 12:04:29 +01:00
|
|
|
ALTER TABLE tables_priv
|
|
|
|
MODIFY Column_priv set('Select','Insert','Update','References')
|
|
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
|
|
|
|
MODIFY Table_priv set('Select','Insert','Update','Delete','Create',
|
|
|
|
'Drop','Grant','References','Index','Alter',
|
|
|
|
'Create View','Show view')
|
|
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
|
|
|
|
COMMENT='Table privileges';
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# columns_priv
|
|
|
|
#
|
|
|
|
|
|
|
|
# Name change of Type -> Column_priv from MySQL 3.22.12
|
2006-11-29 12:04:29 +01:00
|
|
|
ALTER TABLE columns_priv
|
|
|
|
CHANGE Type Column_priv set('Select','Insert','Update','References')
|
|
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2006-11-29 12:04:29 +01:00
|
|
|
ALTER TABLE columns_priv
|
|
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
|
|
MODIFY User char(16) NOT NULL default '',
|
|
|
|
MODIFY Table_name char(64) NOT NULL default '',
|
|
|
|
MODIFY Column_name char(64) NOT NULL default '',
|
|
|
|
ENGINE=MyISAM,
|
|
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin,
|
|
|
|
COMMENT='Column privileges';
|
|
|
|
|
|
|
|
ALTER TABLE columns_priv
|
|
|
|
MODIFY Column_priv set('Select','Insert','Update','References')
|
|
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# Add the new 'type' column to the func table.
|
|
|
|
#
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# Change the user,db and host tables to current format
|
|
|
|
#
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
# Detect whether we had Show_db_priv
|
|
|
|
SET @hadShowDbPriv:=0;
|
|
|
|
SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
|
|
|
|
|
|
|
|
ALTER TABLE user
|
2005-02-11 05:25:14 +01:00
|
|
|
ADD Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_priv,
|
|
|
|
ADD Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_db_priv,
|
|
|
|
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Super_priv,
|
|
|
|
ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
|
|
|
|
ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
|
|
|
|
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;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Convert privileges so that users have similar privileges as before
|
2004-03-19 17:33:38 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Add fields that can be used to limit number of questions and connections
|
|
|
|
# for some users.
|
2003-06-04 17:28:51 +02:00
|
|
|
|
|
|
|
ALTER TABLE user
|
2004-10-02 21:20:08 +02:00
|
|
|
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;
|
2003-06-04 17:28:51 +02:00
|
|
|
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# Add Create_tmp_table_priv and Lock_tables_priv to db and host
|
|
|
|
#
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2003-06-04 17:28:51 +02:00
|
|
|
ALTER TABLE db
|
2005-02-11 05:25:14 +01:00
|
|
|
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
2003-06-04 17:28:51 +02:00
|
|
|
ALTER TABLE host
|
2005-02-11 05:25:14 +01:00
|
|
|
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
2003-10-06 21:56:34 +02:00
|
|
|
|
2004-03-19 17:33:38 +01:00
|
|
|
alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
|
2006-11-29 12:04:29 +01:00
|
|
|
|
2004-03-19 17:33:38 +01:00
|
|
|
|
|
|
|
alter table db comment='Database privileges';
|
|
|
|
alter table host comment='Host privileges; Merged with database privileges';
|
|
|
|
alter table user comment='Users and global privileges';
|
|
|
|
alter table func comment='User defined functions';
|
2004-09-11 17:46:06 +02:00
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
# Convert all tables to UTF-8 with binary collation
|
|
|
|
# and reset all char columns to correct width
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE user
|
|
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
|
|
MODIFY User char(16) NOT NULL default '',
|
|
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE user
|
2005-10-13 16:16:19 +02:00
|
|
|
MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '',
|
2005-02-11 05:25:14 +01:00
|
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
2006-11-21 16:31:44 +01:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE db
|
|
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
|
|
MODIFY User char(16) NOT NULL default '',
|
|
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE db
|
|
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
2006-11-21 16:31:44 +01:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE host
|
|
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE host
|
|
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
2006-11-21 16:31:44 +01:00
|
|
|
|
2005-02-11 05:25:14 +01:00
|
|
|
ALTER TABLE func
|
|
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE func
|
|
|
|
MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
|
|
|
|
|
2004-09-11 17:46:06 +02:00
|
|
|
#
|
|
|
|
# Detect whether we had Create_view_priv
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
2004-09-11 17:46:06 +02:00
|
|
|
SET @hadCreateViewPriv:=0;
|
|
|
|
SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%';
|
|
|
|
|
2004-07-16 00:15:55 +02:00
|
|
|
#
|
2004-07-19 05:16:42 +02:00
|
|
|
# Create VIEWs privileges (v5.0)
|
2004-07-16 00:15:55 +02:00
|
|
|
#
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE db ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE db MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE host ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE host MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE user ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
|
2004-07-16 00:15:55 +02:00
|
|
|
|
|
|
|
#
|
2004-07-19 05:16:42 +02:00
|
|
|
# Show VIEWs privileges (v5.0)
|
2004-07-16 00:15:55 +02:00
|
|
|
#
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE db MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
2004-03-19 17:33:38 +01:00
|
|
|
|
2004-09-11 17:46:06 +02:00
|
|
|
#
|
|
|
|
# Assign create/show view privileges to people who have create provileges
|
|
|
|
#
|
|
|
|
UPDATE user SET Create_view_priv=Create_priv, Show_view_priv=Create_priv where user<>"" AND @hadCreateViewPriv = 0;
|
|
|
|
|
2004-12-23 11:46:24 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
SET @hadCreateRoutinePriv:=0;
|
|
|
|
SELECT @hadCreateRoutinePriv:=1 FROM user WHERE Create_routine_priv LIKE '%';
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create PROCEDUREs privileges (v5.0)
|
|
|
|
#
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE db ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE db MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
|
|
|
2005-05-02 19:25:47 +02:00
|
|
|
ALTER TABLE host ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE host MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE user ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
2004-12-23 11:46:24 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Alter PROCEDUREs privileges (v5.0)
|
|
|
|
#
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE db ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE db MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
|
|
|
2005-05-02 19:25:47 +02:00
|
|
|
ALTER TABLE host ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE host MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE user ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
2004-12-23 11:46:24 +01:00
|
|
|
|
2005-02-18 03:07:14 +01:00
|
|
|
ALTER TABLE db ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE db MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
|
|
|
2005-05-02 19:25:47 +02:00
|
|
|
ALTER TABLE host ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE host MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
2004-12-23 11:46:24 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Assign create/alter routine privileges to people who have create privileges
|
|
|
|
#
|
|
|
|
UPDATE user SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv where user<>"" AND @hadCreateRoutinePriv = 0;
|
|
|
|
UPDATE db SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where user<>"" AND @hadCreateRoutinePriv = 0;
|
2005-02-08 03:40:14 +01:00
|
|
|
UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where @hadCreateRoutinePriv = 0;
|
2004-12-23 11:46:24 +01:00
|
|
|
|
2004-12-29 18:30:37 +01:00
|
|
|
#
|
2007-02-26 11:49:24 +01:00
|
|
|
# Add max_user_connections resource limit
|
2004-12-29 18:30:37 +01:00
|
|
|
#
|
|
|
|
ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections;
|
|
|
|
|
2005-03-22 15:54:18 +01:00
|
|
|
#
|
|
|
|
# user.Create_user_priv
|
|
|
|
#
|
|
|
|
|
|
|
|
SET @hadCreateUserPriv:=0;
|
|
|
|
SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%';
|
|
|
|
|
|
|
|
ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
2006-11-21 16:31:44 +01:00
|
|
|
ALTER TABLE user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
2005-03-22 15:54:18 +01:00
|
|
|
UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
|
|
|
|
WHERE @hadCreateUserPriv = 0 AND
|
|
|
|
(user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# procs_priv
|
|
|
|
#
|
2004-12-23 11:46:24 +01:00
|
|
|
|
2006-11-29 12:04:29 +01:00
|
|
|
ALTER TABLE procs_priv
|
|
|
|
ENGINE=MyISAM,
|
|
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
|
|
|
|
ALTER TABLE procs_priv
|
|
|
|
MODIFY Proc_priv set('Execute','Alter Routine','Grant')
|
|
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
|
|
|
|
ALTER TABLE procs_priv
|
|
|
|
ADD Routine_type enum('FUNCTION','PROCEDURE')
|
|
|
|
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
|
|
|
|
|
|
|
|
ALTER TABLE procs_priv
|
|
|
|
MODIFY Timestamp timestamp(14) AFTER Proc_priv;
|
|
|
|
|
2007-02-26 11:49:24 +01:00
|
|
|
#
|
|
|
|
# proc
|
|
|
|
#
|
2004-03-23 12:04:40 +01:00
|
|
|
|
2004-10-14 18:07:09 +02:00
|
|
|
# Correct the name fields to not binary, and expand sql_data_access
|
2004-03-23 12:04:40 +01:00
|
|
|
ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
|
2004-10-14 18:07:09 +02:00
|
|
|
MODIFY specific_name char(64) DEFAULT '' NOT NULL,
|
2005-07-08 16:33:15 +02:00
|
|
|
MODIFY sql_data_access
|
|
|
|
enum('CONTAINS_SQL',
|
|
|
|
'NO_SQL',
|
|
|
|
'READS_SQL_DATA',
|
|
|
|
'MODIFIES_SQL_DATA'
|
|
|
|
) DEFAULT 'CONTAINS_SQL' NOT NULL,
|
2005-07-27 03:08:49 +02:00
|
|
|
MODIFY body longblob DEFAULT '' NOT NULL,
|
2005-03-09 02:40:43 +01:00
|
|
|
MODIFY sql_mode
|
|
|
|
set('REAL_AS_FLOAT',
|
|
|
|
'PIPES_AS_CONCAT',
|
|
|
|
'ANSI_QUOTES',
|
|
|
|
'IGNORE_SPACE',
|
|
|
|
'NOT_USED',
|
|
|
|
'ONLY_FULL_GROUP_BY',
|
|
|
|
'NO_UNSIGNED_SUBTRACTION',
|
|
|
|
'NO_DIR_IN_CREATE',
|
|
|
|
'POSTGRESQL',
|
|
|
|
'ORACLE',
|
|
|
|
'MSSQL',
|
|
|
|
'DB2',
|
|
|
|
'MAXDB',
|
|
|
|
'NO_KEY_OPTIONS',
|
|
|
|
'NO_TABLE_OPTIONS',
|
|
|
|
'NO_FIELD_OPTIONS',
|
|
|
|
'MYSQL323',
|
|
|
|
'MYSQL40',
|
|
|
|
'ANSI',
|
|
|
|
'NO_AUTO_VALUE_ON_ZERO',
|
|
|
|
'NO_BACKSLASH_ESCAPES',
|
|
|
|
'STRICT_TRANS_TABLES',
|
|
|
|
'STRICT_ALL_TABLES',
|
|
|
|
'NO_ZERO_IN_DATE',
|
|
|
|
'NO_ZERO_DATE',
|
|
|
|
'INVALID_DATES',
|
|
|
|
'ERROR_FOR_DIVISION_BY_ZERO',
|
|
|
|
'TRADITIONAL',
|
|
|
|
'NO_AUTO_CREATE_USER',
|
|
|
|
'HIGH_NOT_PRECEDENCE'
|
2005-08-24 01:37:21 +02:00
|
|
|
) DEFAULT '' NOT NULL,
|
2005-07-08 16:33:15 +02:00
|
|
|
DEFAULT CHARACTER SET utf8;
|
|
|
|
|
|
|
|
# Correct the character set and collation
|
|
|
|
ALTER TABLE proc CONVERT TO CHARACTER SET utf8;
|
|
|
|
# Reset some fields after the conversion
|
|
|
|
ALTER TABLE proc MODIFY db
|
|
|
|
char(64) collate utf8_bin DEFAULT '' NOT NULL,
|
|
|
|
MODIFY definer
|
|
|
|
char(77) collate utf8_bin DEFAULT '' NOT NULL,
|
|
|
|
MODIFY comment
|
|
|
|
char(64) collate utf8_bin DEFAULT '' NOT NULL;
|
2006-02-24 17:34:15 +01:00
|
|
|
|
|
|
|
# Activate the new, possible modified privilege tables
|
|
|
|
# This should not be needed, but gives us some extra testing that the above
|
|
|
|
# changes was correct
|
|
|
|
|
|
|
|
flush privileges;
|