mysql - 建角色并赋予数据库权限
-- 创建用户
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
ALTER USER 'username'@'localhost' IDENTIFIED BY 'password';
-- mysql8 的用户可能无法在 navicat 登录,要用下面这种方式
-- MYSQL_NATIVE_PASSWORD 是 mysql 的一种身份验证插件
CREATE USER 'username'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'password';
ALTER USER 'username'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'password';
-- 授权
GRANT ALL ON *.* TO 'username'@'localhost';
-- E.G.
CREATE USER 'golden'@'localhost' IDENTIFIED BY 'gd2017';
GRANT ALL ON med.* TO 'golden'@'localhost';
疯狂的妞妞 :每一天,做什么都好,不要什么都不做!