Home  >  Article  >  Database  >  Fix error 1064 (42000) when creating database in MySQL?

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

WBOY
WBOYforward
2023-09-04 17:49:021500browse

在 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;

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

mysql> create database customer-tracker;

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

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

mysql> create database `customer-tracker`;

This will produce the following output -

Query OK, 1 row affected (0.21 sec)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete