一.第一此登录mysql设置root密码时

SET PASSWORD = PASSWORD('password');

//----------5.7版本以后-----------
ALTER USER USER() IDENTIFIED BY 'password';

“password”替换为tinymeng设置的密码;

二、创建mysql用户拥有外部访问权限

GRANT USAGE ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

//----------5.7版本以后-----------
//创建用户
CREATE USER 'username'@'%'  IDENTIFIED WITH mysql_native_password BY 'username';
//给用户赋全部权限
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'WITH GRANT OPTION;

“username”替换为将要授权的用户名,比如tinymeng;
“password”替换为tinymeng设置的密码;

最后生效授权,刷新权限
FLUSH PRIVILEGES;
Last modification:April 3rd, 2020 at 12:05 am
如果觉得我的文章对你有用,请随意赞赏