输入 mysql -uroot -p 回车然后输入密码
一、 创建用户CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
username: 你将创建用户的名字
localhost : 本地用户,如果想让该用户可以从任意远程主机登陆,可以使用%
identified by : 密码为。。。。。
password : 密码
例: create user'fuck'@'localhost' identified by '123'; create user'fuck'@'%' identified by '123'
二、 授权
GRANT all ON databasename.* TO 'username'@'localhost';
使得username 这个用户 获得能对 databasename 这个数据库中的所有表进行操作
例:create database study charset utf8;
grant all on study.* to 'fuck'@'localhost';
grant all on study.student to 'fuck'@'localhost';
三、删除用户DROP USER 'username'@'localhost';
四、撤销权限
REVOKE all ON databasename.tablename FROM 'username'@'localhost';