一. 創(chuàng)建用戶命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 說明:
例子:CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456'; CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456'; CREATE USER 'pig'@'%' IDENTIFIED BY '123456'; CREATE USER 'pig'@'%' IDENTIFIED BY ''; CREATE USER 'pig'@'%'; 二. 授權(quán):命令:GRANT privileges ON databasename.tablename TO 'username'@'host' 說明:
例子:GRANT SELECT, INSERT ON test.user TO 'pig'@'%'; GRANT ALL ON *.* TO 'pig'@'%'; GRANT ALL ON maindataplus.* TO 'pig'@'%'; 注意:用以上命令授權(quán)的用戶不能給其它用戶授權(quán),如果想讓該用戶可以授權(quán),用以下命令: GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION; 三.設(shè)置與更改用戶密碼命令:SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword'); 如果是當(dāng)前登陸用戶用: SET PASSWORD = PASSWORD("newpassword"); 例子:SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456"); 四. 撤銷用戶權(quán)限命令:REVOKE privilege ON databasename.tablename FROM 'username'@'host'; 說明:privilege, databasename, tablename:同授權(quán)部分 例子:REVOKE SELECT ON *.* FROM 'pig'@'%'; 注意:假如你在給用戶 具體信息可以用命令 五.刪除用戶命令:DROP USER 'username'@'host'; http://blog.csdn.net/piaocoder/article/details/53704126 |
|