mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
75e2c2fd99
Added new commands CREATE USER and RENAME USER. Changed behaviour of DROP USER. Changed an error messages for the new commands. Docs/mysqld_error.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. include/mysqld_error.h: WL#2050 - CREATE USER and DROP USER and RENAME USER Changed an error code for more general use. mysql-test/r/grant.result: WL#2050 - CREATE USER and DROP USER and RENAME USER Changed test results. mysql-test/r/grant2.result: WL#2050 - CREATE USER and DROP USER and RENAME USER New test results. mysql-test/r/ps_1general.result: WL#2050 - CREATE USER and DROP USER and RENAME USER Changed test results. mysql-test/t/grant.test: WL#2050 - CREATE USER and DROP USER and RENAME USER Updated old tests for new behaviour of DROP USER. It does now implicitly remove all privileges and does not fail when privileges are still in place. Fixed a typo, which left an user in the database, whereby other tests could be confused. Added a DROP USER for another test user. mysql-test/t/grant2.test: WL#2050 - CREATE USER and DROP USER and RENAME USER Added new tests for the new features. sql/share/czech/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/danish/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/dutch/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/english/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/estonian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/french/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/german/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/greek/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/hungarian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/italian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/japanese/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/korean/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/norwegian-ny/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/norwegian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/polish/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/portuguese/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/romanian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/russian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/serbian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/slovak/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/spanish/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/swedish/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/share/ukrainian/errmsg.txt: WL#2050 - CREATE USER and DROP USER and RENAME USER Modified an error message for more general use. sql/sql_acl.cc: WL#2050 - CREATE USER and DROP USER and RENAME USER Added a destructor for the GRANT_TABLE object to get rid of a hash_column in cases where a nonsense row was read from the privilege tables. Added code to delete such an object when it is not entered into the column_priv_hash due to a nonsense row. Added function comments to two unmodified functions. Replaced mysql_drop_user() by the implementation of all of the functions as specified in the Low Level Design. sql/sql_acl.h: WL#2050 - CREATE USER and DROP USER and RENAME USER Added prototypes for new functions. sql/sql_lex.h: WL#2050 - CREATE USER and DROP USER and RENAME USER Added new command codes for CREATE USER and RENAME USER. sql/sql_parse.cc: WL#2050 - CREATE USER and DROP USER and RENAME USER Added case clauses for the new commands CREATE USER and RENAME USER. sql/sql_yacc.yy: WL#2050 - CREATE USER and DROP USER and RENAME USER Added syntax for the new commands CREATE USER and RENAME USER, reworked DROP USER, introduced a new 'user_list' and 'rename_list', renamed the old 'user_list' to 'grant_list'. The difference is that 'grant_list' contains 'grant_user' (with optional IDENTIFIED BY), while 'user_list' contains 'user'. Concentrated privilege initializazions into a new section 'clear_privileges'.
225 lines
11 KiB
Text
225 lines
11 KiB
Text
SET NAMES binary;
|
|
drop database if exists mysqltest;
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
delete from mysql.tables_priv where user like 'mysqltest\_%';
|
|
delete from mysql.columns_priv where user like 'mysqltest\_%';
|
|
flush privileges;
|
|
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
|
|
select current_user();
|
|
current_user()
|
|
mysqltest_1@localhost
|
|
select current_user;
|
|
current_user
|
|
mysqltest_1@localhost
|
|
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
|
|
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
|
|
set @@sql_mode='NO_AUTO_CREATE_USER';
|
|
select @@sql_mode;
|
|
@@sql_mode
|
|
NO_AUTO_CREATE_USER
|
|
grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
|
|
ERROR 42000: 'mysqltest_1'@'localhost' is not allowed to create new users
|
|
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
|
|
with grant option;
|
|
show grants for mysqltest_1@localhost;
|
|
Grants for mysqltest_1@localhost
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
|
GRANT ALL PRIVILEGES ON `my\_%`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
|
|
show grants for mysqltest_2@localhost;
|
|
Grants for mysqltest_2@localhost
|
|
GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
|
|
GRANT ALL PRIVILEGES ON `my\_1`.* TO 'mysqltest_2'@'localhost' WITH GRANT OPTION
|
|
show grants for mysqltest_3@localhost;
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_3' on host 'localhost'
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
flush privileges;
|
|
create database mysqltest;
|
|
grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
|
|
flush privileges;
|
|
use mysqltest;
|
|
create table t1 (id int primary key, data varchar(255));
|
|
show grants for current_user();
|
|
Grants for mysqltest_1@localhost
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
|
GRANT SELECT, INSERT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
|
use mysqltest;
|
|
insert into t1 values (1, 'I can''t change it!');
|
|
update t1 set data='I can change it!' where id = 1;
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
|
|
insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
|
|
select * from t1;
|
|
id data
|
|
1 I can't change it!
|
|
drop table t1;
|
|
drop database mysqltest;
|
|
use test;
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
flush privileges;
|
|
set sql_mode='maxdb';
|
|
drop table if exists t1, t2;
|
|
create table t1(c1 int);
|
|
create table t2(c1 int, c2 int);
|
|
create user 'mysqltest_1';
|
|
create user 'mysqltest_1';
|
|
ERROR HY000: Operation CREATE USER failed for 1 of the requested users
|
|
create user 'mysqltest_2' identified by 'Mysqltest-2';
|
|
create user 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
|
|
grant select on *.* to 'mysqltest_2';
|
|
grant insert on test.* to 'mysqltest_2';
|
|
grant update on test.t1 to 'mysqltest_2';
|
|
grant update (c2) on test.t2 to 'mysqltest_2';
|
|
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
|
|
host user password
|
|
% mysqltest_1
|
|
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
|
|
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
|
|
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
|
|
host db user
|
|
% test mysqltest_2
|
|
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
|
|
host db user table_name
|
|
% test mysqltest_2 t1
|
|
% test mysqltest_2 t2
|
|
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
|
|
host db user table_name column_name
|
|
% test mysqltest_2 t2 c2
|
|
show grants for 'mysqltest_1';
|
|
Grants for mysqltest_1@%
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'%'
|
|
show grants for 'mysqltest_2';
|
|
Grants for mysqltest_2@%
|
|
GRANT SELECT ON *.* TO 'mysqltest_2'@'%' IDENTIFIED BY PASSWORD '*BD447CBA355AF58578D3AE33BA2E2CD388BA08D1'
|
|
GRANT INSERT ON "test".* TO 'mysqltest_2'@'%'
|
|
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_2'@'%'
|
|
GRANT UPDATE ON "test"."t1" TO 'mysqltest_2'@'%'
|
|
drop user 'mysqltest_1';
|
|
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
|
|
host user password
|
|
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
|
|
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
|
|
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
|
|
host db user
|
|
% test mysqltest_2
|
|
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
|
|
host db user table_name
|
|
% test mysqltest_2 t1
|
|
% test mysqltest_2 t2
|
|
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
|
|
host db user table_name column_name
|
|
% test mysqltest_2 t2 c2
|
|
show grants for 'mysqltest_1';
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
|
|
rename user 'mysqltest_2' to 'mysqltest_1';
|
|
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
|
|
host user password
|
|
% mysqltest_1 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
|
|
% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
|
|
select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
|
|
host db user
|
|
% test mysqltest_1
|
|
select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
|
|
host db user table_name
|
|
% test mysqltest_1 t1
|
|
% test mysqltest_1 t2
|
|
select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
|
|
host db user table_name column_name
|
|
% test mysqltest_1 t2 c2
|
|
show grants for 'mysqltest_1';
|
|
Grants for mysqltest_1@%
|
|
GRANT SELECT ON *.* TO 'mysqltest_1'@'%' IDENTIFIED BY PASSWORD '*BD447CBA355AF58578D3AE33BA2E2CD388BA08D1'
|
|
GRANT INSERT ON "test".* TO 'mysqltest_1'@'%'
|
|
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_1'@'%'
|
|
GRANT UPDATE ON "test"."t1" TO 'mysqltest_1'@'%'
|
|
drop user 'mysqltest_1', 'mysqltest_3';
|
|
drop table t1, t2;
|
|
insert into mysql.db set user='mysqltest_1', db='%', host='%';
|
|
flush privileges;
|
|
show grants for 'mysqltest_1';
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
|
|
revoke all privileges, grant option from 'mysqltest_1';
|
|
ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users
|
|
drop user 'mysqltest_1';
|
|
select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
|
|
host db user
|
|
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
|
|
flush privileges;
|
|
show grants for 'mysqltest_1';
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
|
|
drop user 'mysqltest_1';
|
|
select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
|
|
host db user table_name
|
|
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
|
|
flush privileges;
|
|
show grants for 'mysqltest_1';
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
|
|
drop user 'mysqltest_1';
|
|
select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
|
|
host db user table_name column_name
|
|
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
|
|
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
|
|
create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
|
|
rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';
|
|
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
|
|
ERROR HY000: Operation DROP USER failed for 3 of the requested users
|
|
drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';
|
|
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
|
|
create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';
|
|
ERROR HY000: Operation CREATE USER failed for 1 of the requested users
|
|
rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';
|
|
ERROR HY000: Operation RENAME USER failed for 1 of the requested users
|
|
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
|
|
drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';
|
|
ERROR HY000: Operation DROP USER failed for 1 of the requested users
|
|
create user 'mysqltest_2' identified by 'Mysqltest-2';
|
|
drop user 'mysqltest_2' identified by 'Mysqltest-2';
|
|
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Mysqltest-2'' at line 1
|
|
create user '%@b'@'b';
|
|
show grants for '%@b'@'b';
|
|
Grants for %@b@b
|
|
GRANT USAGE ON *.* TO '%@b'@'b'
|
|
grant select on mysql.* to '%@b'@'b';
|
|
show grants for '%@b'@'b';
|
|
Grants for %@b@b
|
|
GRANT USAGE ON *.* TO '%@b'@'b'
|
|
GRANT SELECT ON "mysql".* TO '%@b'@'b'
|
|
rename user '%@b'@'b' to '%@a'@'a';
|
|
show grants for '%@b'@'b';
|
|
ERROR 42000: There is no such grant defined for user '%@b' on host 'b'
|
|
show grants for '%@a'@'a';
|
|
Grants for %@a@a
|
|
GRANT USAGE ON *.* TO '%@a'@'a'
|
|
GRANT SELECT ON "mysql".* TO '%@a'@'a'
|
|
drop user '%@a'@'a';
|
|
create user mysqltest_2@localhost;
|
|
grant usage on *.* to mysqltest_2@localhost with grant option;
|
|
select host,user,password from mysql.user order by host,user,password;
|
|
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysql'
|
|
create user mysqltest_A@'%';
|
|
rename user mysqltest_A@'%' to mysqltest_B@'%';
|
|
drop user mysqltest_B@'%';
|
|
drop user mysqltest_2@localhost;
|
|
create user mysqltest_3@localhost;
|
|
grant all privileges on mysql.* to mysqltest_3@localhost;
|
|
select host,user,password from mysql.user order by host,user,password;
|
|
host user password
|
|
% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
|
|
127.0.0.1 root
|
|
chilla%
|
|
chilla% root
|
|
localhost
|
|
localhost mysqltest_3
|
|
localhost root
|
|
insert into mysql.user set host='%', user='mysqltest_B';
|
|
create user mysqltest_A@'%';
|
|
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
|
|
rename user mysqltest_B@'%' to mysqltest_C@'%';
|
|
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
|
|
drop user mysqltest_B@'%';
|
|
ERROR 42000: Access denied for user 'mysqltest_3'@'localhost' to database 'mysql'
|
|
drop user mysqltest_B@'%';
|
|
drop user mysqltest_3@localhost;
|