欢迎光临
感受代码之美

mysql创建用户及赋予权限

mysql新版本和以前的版本有些区别:

mysql 8以前的版本

CREATE USER 'seafile' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON *.* TO 'seafile'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
ALTER USER 'seafile'@'%' IDENTIFIED WITH mysql_native_password BY 'Passw0rd';

mysql 8使用以前的赋予权限命令会报下面的错误:

mysql> grant all privileges  on *.* to [email protected]'localhost' identified by 'Passw0rd';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Passw0rd'' at line 1

mysql 8以前的版本

CREATE USER 'seafile' IDENTIFIED BY 'Passw0rd';
grant all privileges  on *.* to [email protected]'localhost' IDENTIFIED BY 'Passw0rd';
grant all privileges  on *.* to [email protected]'127.0.0.1' IDENTIFIED BY "Passw0rd";
grant all privileges  on *.* to [email protected]'%' IDENTIFIED BY "Passw0rd";
FLUSH PRIVILEGES;

grant all privileges  on *.* to [email protected]'10.47.0.238' IDENTIFIED BY "Passw0rd";
grant all privileges  on *.* to [email protected]'10.47.0.238' IDENTIFIED BY "Passw0rd";
grant all privileges  on *.* to [email protected]'%' IDENTIFIED BY "Passw0rd";
FLUSH PRIVILEGES;
转载请注明来源:四个空格 » mysql创建用户及赋予权限

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址