首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

MySQL顶用户的创建及删除

2013-01-28 
MySQL中用户的创建及删除4. 撤销用户权限?? 命令: REVOKE privilege ON databasename.tablename FROM use

MySQL中用户的创建及删除
4. 撤销用户权限
?? 命令: REVOKE privilege ON databasename.tablename FROM 'username'@'host';
?? 说明: privilege, databasename, tablename - 同授权部分.
?? 例子: REVOKE SELECT ON *.* FROM 'username'@'%';
?? 注意: 假如你在给用户'username'@'%'授权的时候是这样的(或类似的):
??????? GRANT SELECT ON test.user TO 'username'@'%',
??????? 则在使用REVOKE SELECT ON *.* FROM 'username'@'%';
??????? 命令并不能撤销该用户对test数据库中user表的SELECT 操作.
??????? 相反,如果授权使用的是GRANT SELECT ON *.* TO 'username'@'%';
??????? 则REVOKE SELECT ON test.user FROM 'username'@'%';
??????? 命令也不能撤销该用户对test数据库中user表的Select 权限.
?? 具体信息可以用命令SHOW GRANTS FOR 'username'@'%'; 查看, 或者:
?? select User, Host from mysql.user;
?? 刷新系统权限表:flush privileges;
5. 删除用户
?? 命令: DROP USER 'username'@'host';
?? Delete FROM user Where User="hive" and Host="localhost";
?? drop database metastore_db;
??
?? 附表:在MySQL中的操作权限
?? ALTER??????????????????? Allows use of ALTER TABLE.
?? ALTER ROUTINE??????????? Alters or drops stored routines.
?? CREATE?????????????????? Allows use of CREATE TABLE.
?? CREATE ROUTINE?????????? Creates stored routines.
?? CREATE TEMPORARY TABLE?? Allows use of CREATE TEMPORARY TABLE.
?? CREATE USER????????????? Allows use of CREATE USER, DROP USER,
??????????????????????????? RENAME USER, and REVOKE ALL PRIVILEGES.
?? CREATE VIEW????????????? Allows use of CREATE VIEW.
?? DELETE?????????????????? Allows use of DELETE.
?? DROP???????????????????? Allows use of DROP TABLE.
?? EXECUTE????????????????? Allows the user to run stored routines.
?? FILE???????????????????? Allows use of SELECT... INTO OUTFILE and
??????????????????????????? LOAD DATA INFILE.
?? INDEX??????????????????? Allows use of CREATE INDEX and DROP INDEX.
?? INSERT?????????????????? Allows use of INSERT.
?? LOCK TABLES????????????? Allows use of LOCK TABLES on tables for
??????????????????????????? which the user also has SELECT privileges.
?? PROCESS????????????????? Allows use of SHOW FULL PROCESSLIST.
?? RELOAD?????????????????? Allows use of FLUSH.
?? REPLICATION????????????? Allows the user to ask where slave or master
?? CLIENT?????????????????? servers are.
?? REPLICATION SLAVE??????? Needed for replication slaves.
?? SELECT?????????????????? Allows use of SELECT.
?? SHOW DATABASES?????????? Allows use of SHOW DATABASES.
?? SHOW VIEW??????????????? Allows use of SHOW CREATE VIEW.
?? SHUTDOWN???????????????? Allows use of mysqladmin shutdown.
?? SUPER??????????????????? Allows use of CHANGE MASTER, KILL, PURGE MASTER
??????????????????????????? LOGS, and SET GLOBAL SQL statements. Allows
??????????????????????????? mysqladmin debug command. Allows one extra
??????????????????????????? connection to be made if maximum connections are
??????????????????????????? reached.
?? UPDATE?????????????????? Allows use of UPDATE.
?? USAGE??????????????????? Allows connection without any specific privileges.
6. 其他常见操作
?? (1)列出所有数据库: show database;
?? (2)切换数据库: use '数据库名';
?? (3)列出所有表: show tables;
?? (4)显示数据表结构: describe 表名;
?? (5)删除数据库和数据表: drop database 数据库名;
?? //注意,如果数据库名包含“.”,那么在删除时需要加上引用引号,如:
?? dropo database `php.sql`;
?? drop table 数据表名;

热点排行