简体   繁体   中英

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 '-db'

I'm trying to delete a database inside an RDS MySQL instance and I get the following error . Can someone kindly help me resolve this issue

  [ec2-user@ip-10-10-1-14 ~]$ mysql -h wda2d.cmkridjjwpjp.ap-southeast-2.rds.amazonaws.com -u happy-p
  Enter password:
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 6241
  Server version: 5.6.19-log MySQL Community Server (GPL)

  Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.

  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  mysql> show databases;
  +-----------------------+
  | Database              |
  +-----------------------+
  | information_schema    |
  | database              |
  | innodb                |
  | mysql                 |
  | performance_schema    |
  | richard-db            |
  | word-db               |
  | wordpress-db          |
  +-----------------------+
  10 rows in set (0.00 sec)

  mysql> DROP DATABASE wordpress-db;
  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 '-db' at line 1
  mysql> Ctrl-C -- exit!
  Aborted

Dashes are not valid identifier characters unless you wrap them in ticks. (Otherwise they represent the math operation of subtraction).

DROP DATABASE `wordpress-db`;

I recommend renaming those tables to follow best practices and use underscores instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question MySQL error: 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 my sql :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 '' sql_query: 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 Error: 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 ' Error AS-->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 ', ERROR 1064: 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 ') Error:1064, ("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 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 '')' at line 1 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 ') 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 '0'' at line 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM