繁体   English   中英

MySql 在没有明显错误的情况下创建用户期间出现语法错误

[英]MySql syntax error during user creation when there is no apparent error

我正在尝试使用以下指南使用 Ubuntu 安装 Moodle:Ubuntu 的分步安装指南

我目前在第 6 步,我必须创建一个具有正确权限的 mySQL 用户,这就是我遇到困难的地方。

第一个命令 - create user 'user1'@'localhost' IDENTIFIED BY 'password1'; 工作良好

但是第二个命令 -

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO user1@localhost
IDENTIFIED BY 'password1';

返回错误消息 - 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 'password1'' at line 1 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 'password1'' at line 1

安装手册提到这可能是个问题,所以建议我使用 - SELECT password('password1'); 为了得到一个 hash 的值来克服这个问题。

但是,它没有给我一个 hash 值,而是出现了相同的错误 - 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 '('password1')' at line 1 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 '('password1')' at line 1

我是这一切的初学者,所以我很感激任何回复,提前致谢!

您需要在命令中的名称和主机周围加上撇号,例如:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'@'localhost'
IDENTIFIED BY 'password1';

编辑

根据评论,稍微更改命令修复了语法错误:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'@'localhost';

首先创建由“你的密码”标识的用户“moodleuser”@“localhost”;

然后授予 select,insert,update,delete,create,create temporary tables,drop,index,alter on moodle.* to 'moodleuser'@'localhost';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM