mysql5.6创建新用户并给授权指定的数据库权限

use mysql;

CREATE USER 'hero'@'%' IDENTIFIED BY '3f33233ec786';

'%' - 所有情况都能访问
‘localhost’ - 本机才能访问
’111.222.33.44‘ - 指定 ip 才能访问

update mysql.user set password=password('新密码') where user='hero';

grant all privileges on 想授权的数据库.* to 'user1'@'%';

all 可以替换为 select,delete,update,create,drop

刷新权限

FLUSH PRIVILEGES;

原文地址:https://www.cnblogs.com/buddyquan/p/8808935.html