📄 grant2.result
字号:
SET NAMES binary;drop database if exists mysqltest;drop database if exists mysqltest_1;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\_1`.* to mysqltest_1@localhost with grant option;grant create user on *.* to mysqltest_1@localhost;create user mysqltest_2@localhost;grant select on `my\_1`.* to mysqltest_2@localhost;grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';ERROR 42000: You must have privileges to update tables in the mysql database to be able to change passwords for othersgrant update on mysql.* to mysqltest_1@localhost;grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';grant select on `my\_1`.* to mysqltest_3@localhost;grant insert on mysql.* to mysqltest_1@localhost;grant select on `my\_1`.* to mysqltest_3@localhost;grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass';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;grant create user on *.* to mysqltest_1@localhost;select current_user();current_user()mysqltest_1@localhostgrant 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_modeNO_AUTO_CREATE_USERgrant select on `my\_1`.* to mysqltest_4@localhost with grant option;ERROR 42000: Can't find any matching row in the user tablegrant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'with grant option;show grants for mysqltest_1@localhost;Grants for mysqltest_1@localhostGRANT CREATE USER ON *.* TO 'mysqltest_1'@'localhost'GRANT ALL PRIVILEGES ON `my\_%`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTIONshow grants for mysqltest_2@localhost;Grants for mysqltest_2@localhostGRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'GRANT ALL PRIVILEGES ON `my\_1`.* TO 'mysqltest_2'@'localhost' WITH GRANT OPTIONshow 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_1;grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;select current_user();current_user()mysqltest_1@localhostshow databases;Databaseinformation_schemamysqltest_1testgrant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_1'show grants for mysqltest_1@localhost;Grants for mysqltest_1@localhostGRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'GRANT ALL PRIVILEGES ON `mysqltest\_1`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTIONdelete from mysql.user where user like 'mysqltest\_%';delete from mysql.db where user like 'mysqltest\_%';drop database mysqltest_1;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@localhostGRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'GRANT SELECT, INSERT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'insert into t1 values (1, 'I can''t change it!');update t1 set data='I can change it!' where id = 1;ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 't1'insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 't1'select * from t1;id data1 I can't change it!drop table t1;delete from mysql.user where user like 'mysqltest\_%';delete from mysql.db where user like 'mysqltest\_%';flush privileges;create table t1 (a int, b int);grant select (a) on t1 to mysqltest_1@localhost with grant option;grant select (a,b) on t1 to mysqltest_2@localhost;ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't1'grant select on t1 to mysqltest_3@localhost;ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'drop table t1;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;drop database mysqltest;use test;create user mysqltest_1@host1;create user mysqltest_2@host2;create user mysqltest_3@host3;create user mysqltest_4@host4;create user mysqltest_5@host5;create user mysqltest_6@host6;create user mysqltest_7@host7;flush privileges;drop user mysqltest_3@host3;drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;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 'mysqltest_1'@'%'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 fffffffffffffffffffffffffffffffffffffffffselect host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;host db user% test mysqltest_2select 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 t2select 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 c2show 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 fffffffffffffffffffffffffffffffffffffffffselect host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;host db user% test mysqltest_2select 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 t2select 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 c2show 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 fffffffffffffffffffffffffffffffffffffffffselect host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -