MYSQL用户授权

对用户授权
mysql>grant rights on database.* to user@host identified by "pass";

例1:

增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。

grant all privileges on discuz.* to webadmin@"localhost" Identified by "Xxie$%&90" WITH GRANT OPTION;

ON 子句中*.* 说明符的意思是“所有数据库,所有的表”


例2:

增加一个用户test2密码为abc, 让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作。

grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";


例子3

增加一个用户custom,他能从主机localhost、server.domain和whitehouse.gov连接。他只想要从 localhost存取bankaccount数据库,从whitehouse.gov存取expenses数据库和从所有3台主机存取customer 数据库。他想要从所有3台主机上使用口令stupid。

为了使用GRANT语句设置个用户的权限,运行这些命令:

shell> mysql --user=root mysql

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ON bankaccount.* TO custom@localhost  IDENTIFIED BY 'stupid';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ON expenses.*  TO [email protected] IDENTIFIED BY 'stupid';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
        ON customer.* TO mailto:custom@%20  IDENTIFIED BY 'stupid';

==============================================
权限信息用user、db、host、tables_priv和columns_priv表被存储在mysql数据库中(即在名为mysql的数据库中)。
 

你可能感兴趣的:(查询,localhost,database,identified)