简体   繁体   English

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

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

I'm trying to install Moodle using Ubuntu using the following guide: Step-by-step Installation Guide for Ubuntu我正在尝试使用以下指南使用 Ubuntu 安装 Moodle:Ubuntu 的分步安装指南

I'm currently on step 6 where I have to create a mySQL user with the correct permissions and this is where I'm getting stuck.我目前在第 6 步,我必须创建一个具有正确权限的 mySQL 用户,这就是我遇到困难的地方。

The 1st command - create user 'user1'@'localhost' IDENTIFIED BY 'password1';第一个命令 - create user 'user1'@'localhost' IDENTIFIED BY 'password1'; works fine工作良好

However the 2nd command -但是第二个命令 -

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

Returns the error message - 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 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

The installation manual mentions that this may be a problem so advises me to use - SELECT password('password1');安装手册提到这可能是个问题,所以建议我使用 - SELECT password('password1'); in order to get a hash value to overcome the problem.为了得到一个 hash 的值来克服这个问题。

However instead of giving me a hash value it comes up with the same error of - 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但是,它没有给我一个 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

I am a beginner to all this so I'd appreciate any responses, thanks in advance!我是这一切的初学者,所以我很感激任何回复,提前致谢!

You need apostrophes around the name and the host in your command, like:您需要在命令中的名称和主机周围加上撇号,例如:

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

EDIT编辑

According to the comments, slightly changing the command fixed the syntax error:根据评论,稍微更改命令修复了语法错误:

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

First Create user 'moodleuser'@'localhost' identified by 'yourpassword';首先创建由“你的密码”标识的用户“moodleuser”@“localhost”;

Then grant select,insert,update,delete,create,create temporary tables,drop,index,alter on moodle.* to '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