一、登录Mysql
mysql -h 127.0.0.1 -uroot -p
二、查看所有用户
mysql> select user,host,password from mysql.user;
三、添加用户及权限
mysql>grant all privileges on *.* to 'famiover'@'%'identified by '123456' with grant option ;
mysql>flush privileges;
*.* 表示所有数据库以及数据库下的表, 'famiover'@'%'表示famiover账号在所有IP下都可以访问,可以将%换成指定IP来限制用户登录,如:192.168.%.% ;with grant option 表示可以将该权限授权给其他账号。
四、查看某一用户权限
mysql> show grants for 'famiover' @ '%';
五、撤销用户权限
mysql> revoke all on *.* from 'famiover' @ '%' ;
mysql> flush privileges;