标签:授权 log grant form l数据库 erro bsp set ide
登录MySQL
> mysql -h192.168.56.1 -P33060 -uroot -p
Enter password: ****
1. 添加用户
insert into mysql.user(host,user,password) values(‘%‘, ‘xiaoming‘, password(‘xiaoming123‘));
现在可以使用帐号(xiaoming,xiaoming123)登录MySQL了。但是只有默认权限,仅能操作两个数据库,information_schema和test
2. 授权
grant <权限列表> on <关系> to <用户/角色>
grant insert on school.* to xiaoming
此时,用户xiaoming就拥有了对数据库school的insert权限。
mysql> show databases; ---授权前 +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec) mysql> show databases; --- 授权后 +--------------------+ | Database | +--------------------+ | information_schema | | school | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> use school; Database changed mysql> insert into student(name,score) values(‘xiaoming‘,60); Query OK, 1 row affected (0.08 sec) mysql> select * from student; ERROR 1142 (42000): SELECT command denied to user ‘xiaoming‘@‘10.0.2.2‘ for table ‘student‘
3. 添加用户和授权
grant <权限> on <关系> to ‘<用户>‘@‘<主机>‘ identified by ‘<密码>‘
mysql> grant select on school.* to xiaoqiang@‘%‘ identified by ‘xiaoqiang123‘;
添加一个新用户并授权
4. 创建角色
标签:授权 log grant form l数据库 erro bsp set ide
原文地址:http://www.cnblogs.com/lhat/p/6901511.html