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';

posted on 2020-04-02 15:50  疯狂的妞妞  阅读(855)  评论(0编辑  收藏  举报

导航