一、建库
二、创建用户
create user 'username'@'host' identified by 'password';
‘username’@‘host’ 中 若host为localhost为本地访问,若host为%则允许远程访问。
Tips:需要同时创建’grade’@'localhost’用户,否则会出现如下错误。
三、授权
//若需要整个库下所有表,则用 Datebase.*,所有库下所有表则用 *.*
grant all on 数据库名.表名 to ‘用户名’@‘host名’ with grant option;
四、更新权限
flush privileges;
五、检查结果
使用新用户登录数据库。