mysql - 您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在 '-db' 附近使用的正确语法

标签 mysql sql mysql-error-1064 sql-drop

我正在尝试删除 RDS MySQL 实例中的数据库,但出现以下错误。有人可以帮我解决这个问题

  [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

最佳答案

破折号不是有效的标识符字符,除非您将它们包裹在刻度中。 (否则它们代表减法的数学运算)。

DROP DATABASE `wordpress-db`;

我建议重命名这些表以遵循最佳实践并改用下划线。

关于mysql - 您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在 '-db' 附近使用的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28445024/

相关文章:

php mysql查询条件oop

mysql - 将古吉拉特语文本插入 MySQL 表会导致出现垃圾字符和不可读的文本

mysql - 运行 mysql_install_db 时出错 : could not find ./bin/my_print_defaults

具有连接数和案例数的 Mysql 查询 - 添加更多连接和子查询

sql - CONTAINSTABLE 不适用于单个字符

MySQL 每组前 2 条记录

php - 根据另一列的值按不同列排序

mysql - CentOS下无法启动MySQL

mysql - 如何创建具有复合外键的表

MySql 创建表时出错