php SQL 语法错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在附近使用的正确语法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36631676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:51:55  来源:igfitidea点击:

error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

phpmysqlapacheubuntu-server

提问by user2950680

I ran this command :

我运行了这个命令:

CREATE DATABASE wordpress;

And I got

我得到了

Query OK, 1 row affected (0.00 sec)

查询正常,1 行受影响(0.00 秒)

I ran the second command :

我运行了第二个命令:

CREATE USER wordpressuser@localhost IDENTIFIED BY ‘password';

And I got:

我得到了:

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 '‘password'' at line 1

ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的“密码”附近使用的正确语法

What am I doing wrong? Running a freshly installed Ubuntu 14.04 Server and trying to make a database for Wordpress.

我究竟做错了什么?运行新安装的 Ubuntu 14.04 服务器并尝试为 Wordpress 创建数据库。

回答by Mawia HL

Try this:

尝试这个:

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Remember the quote in used is not around the @ symbol, and it is not ‘ ' but ' '. And the first thing to do is to provide the user with access to the information this wordpressuser will need.

请记住 used 中的引号不在 @ 符号周围,它不是 ' ' 而是 ' '。首先要做的是让用户能够访问这个 wordpressuser 需要的信息。

GRANT ALL PRIVILEGES ON * . * TO 'wordpressuser'@'localhost';

The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.

该命令中的星号分别表示它们可以访问的数据库和表——该特定命令允许用户读取、编辑、执行和执行跨所有数据库和表的所有任务。

Once you have finalized the permissions that you want to set up for your new wordpressuser, always be sure to reload all the privileges.

一旦确定了要为新 wordpressuser 设置的权限,请务必重新加载所有权限。

FLUSH PRIVILEGES;

回答by DhruvJoshi

Try the below query

试试下面的查询

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';