2015-02-11 105 views
1

我試圖刪除RDS MySQL實例中的數據庫,並且出現以下錯誤。有人可以幫我解決這個問題你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊,以在'-db'附近使用正確的語法

[[email protected] ~]$ 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 
+1

請在drop語句中用''qoutes – 2015-02-11 01:26:00

回答

5

除非你用蜱包裝它們,否則短劃線不是有效的標識字符。 (否則它們表示減法的數學運算)。

DROP DATABASE `wordpress-db`; 

我建議重命名這些表以遵循最佳實踐並改爲使用下劃線。

+0

mysql> DROP DATABASE'word-db'; 錯誤1064(42000):您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,在第1行''word-db''附近使用正確的語法。 – Rocky 2015-02-11 01:28:03

+0

您使用單引號而不是蜱。這仍然不正確。 – 2015-02-11 01:28:46

+0

和'word-db!= wordpress-db' – Alex 2015-02-11 01:30:49

相關問題