MySql_创建用户并赋予权限

时间:2021-12-02 00:42:45

MySql两种创建用户方式

win+r
cmd
C:\Users\Administrator>mysql -uroot -proot
# 方式一
mysql> insert into mysql.user(Host,User,Password) values("localhost","eRrsr",password("eRrsr"));
PS:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。也可以指定某台机器可以远程登录。
# 方式二
mysql> create user 'eRrsr'@'localhost' identiyied BY 'eRrsr';

 MySql授权

mysql> create database eRrsr;
mysql> grant all privileges on eRrsr.* to eRrsr@localhost identified by 'eRrsr';
mysql> flush privileges;
mysql> exit;

 MySql取消授权

mysql> revoke all on eRrsr.* from eRrsr@localhost;
mysql> delete from user whereUser="eRrsr" and Host="localhost";
mysql> drop database eRrsr;
mysql> flush privileges;
mysql> select host,user,password from mysql.user;

 附: 详细操作

http://blog.csdn.net/andy_yf/article/details/7487519