当前位置: 数据库>mysql
mysql数据库添加用户及分配权限具体实现
来源: 互联网 发布时间:2014-10-13
本文导语: 创建用户并分配权限; 代码如下: insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));//创建用户 grant all privileges on dbname.* to 'username'@'%' identified by 'password';//创建用户并分配所有权限 grant select,update on phplampDB.*...
创建用户并分配权限;
insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));//创建用户
grant all privileges on dbname.* to 'username'@'%' identified by 'password';//创建用户并分配所有权限
grant select,update on phplampDB.* to phplamp@localhost identified by '1234';//创建用户并分配权限
update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";//修改用户密码
--删除用户指定权限
revoke insert,update,delete,select ON *.* from 'xbb'@'localhost' IDENTIFIED BY '123';
代码如下:
insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234"));//创建用户
grant all privileges on dbname.* to 'username'@'%' identified by 'password';//创建用户并分配所有权限
grant select,update on phplampDB.* to phplamp@localhost identified by '1234';//创建用户并分配权限
update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";//修改用户密码
--删除用户指定权限
revoke insert,update,delete,select ON *.* from 'xbb'@'localhost' IDENTIFIED BY '123';