30
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【MySQL】ERROR 1064 (42000)を解消する

Last updated at Posted at 2020-05-08

ERROR 1064 (42000)

■エラーコード:1064
■SQLSTATE: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 [入力したSQL文の一部].
■エラーの原因:
SQLの文法に誤りがある。
■エラーへの対処法:
MySQLのバージョンとマニュアルを確認し、SQL文を見直す。 こちらもクォーテーションなど区切り文字には注意が必要。

引用元

データベース接続

$ mysql -u ユーザー名

データベース確認

mysql> show databases; 

データベース削除

mysql> drop database 削除したいデータベース名;
mysql> drop database ajax_todo_development;
Query OK, 3 rows affected (0.28 sec)

データベース削除時エラー(ERROR 1064 (42000))

mysql> drop database git-app_development;
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 '-app_development' at line 1

原因

同じ構文なのにエラーが出るのはデータベース名に-(ハイフン)が含まれているから

解決

-(ハイフン)が含まれる場合は**``(バッククウォート)**で囲むと削除できる
バッククウォート = shift + @で入力できる

mysql> drop database `git-app_development`;
Query OK, 3 rows affected (0.04 sec)
30
35
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?