# 【Mysql】mysqlコマンドを実行する際、パスワードに記号が入っている際の対応方法
> Mysql で mysqlコマンドを実行する際、パスワードに記号が入っている際の対応方法メモ
- Canonical: https://c-a-p-engineer.github.io/mysql-command-password-escape/
- Published: 2022-09-22T09:00:00.000Z
- Modified: 2022-09-22T09:00:00.000Z
- Categories: Database
- Tags: Database, MySQL

# 【Mysql】mysqlコマンドを実行する際にパスワードに記号が入っている際の対応方法
Mysql で mysqlコマンドを実行する際、パスワードに記号が入っている際の対応方法メモ。

## パスワードに記号が入っている
mysqlコマンドを実行する際、パスワードに記号が入ってると以下のようにエラーが発生します。
パスワードには `p@ssword` としています。
```
$ mysql -u[UserName] -pp@assword

Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
```

## シングルクォーテーションで囲む
シングルクォーテーション `'` で囲む事によって記号でも問題なく接続が可能になります。
```
$ mysql -u[UserName] -p'p@assword'
```
