Home > Database > Mysql Tutorial > body text

Fix error 1064 (42000) when creating database in MySQL?

WBOY
Release: 2023-09-04 17:49:02
forward
1570 people have browsed it

在 MySQL 中创建数据库时修复错误 1064 (42000)?

Error 1064 (42000) mainly occurs when the syntax settings are incorrect, that is, an error occurs when applying the backtick symbol, or it may also occur when creating the database without the backtick symbol. Errors, for example, Demo-Table will cause ERROR 1064 (42000) if you use a hyphen in the name.

To eliminate this error you need to use backticks correctly around the database name or use there is nothing. Below is the syntax where we don't use backticks. This works fine -

create database yourDatabaseName;
Copy after login

because adding hyhen to the database name causes an error. Let's implement it while creating the database name -

mysql> create database customer-tracker;
Copy after login

This will produce the following error because we are using a hyphen in the database name which is not acceptable -

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 '-tracker' at line 1
Copy after login

However, we Hyphens in the database name can be fixed by surrounding the name with backtick symbols -

mysql> create database `customer-tracker`;
Copy after login

This will produce the following output -

Query OK, 1 row affected (0.21 sec)
Copy after login

Now the database is created successfully.

The above is the detailed content of Fix error 1064 (42000) when creating database in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template