一、環境
Centos 6.9
Mysql 5.6.40
二、步驟
1、使用root用戶登陸mysql
mysql -uroot -p 輸入密碼:
2、創建新用戶
CREATE USER 'user'@'%' IDENTIFIED BY '123456';
'%' - 所有情況都能訪問 ‘localhost’ - 本機才能訪問 ’192.168.0.1‘ - 指定 ip 才能訪問
3、修改用戶密碼
update mysql.user set password=password('新密碼') where user='user';
4、給用戶添加權限
grant all privileges on 欲授權的數據庫.* to 'user'@'%';
5、刪除用戶
Delete FROM mysql.user Where User='user';
三、切記
對數據庫修改的時候,一定要刷新權限 flush privilege;
大悲無淚--大悟無言--大笑無聲