1、創建用戶
啓用root用戶:mysql -u root -p
創建用戶格式:CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';(注意:別添加其餘空格也別刪除空格)
username: 你將創建用戶的名字
localhost : 本地用戶,如果想讓該用戶可以從任意遠程主機登陸,可以使用%
identified by : 密碼爲。。。。。
password : 密碼
示例: create user 'JvGuang' @ '%' identified by '123456';
2、授權
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';
3、刪除用戶
DROP USER 'username'@'localhost';
4、撤銷權限
REVOKE all ON databasename.tablename FROM 'username'@'localhost';