LoginSignup
33
27

More than 5 years have passed since last update.

パスワードを指定してmysqlコマンドを実行すると表示されるワーニングを回避

Last updated at Posted at 2015-12-18

mysqlコマンドを実行するときに-pでパスワードを付けると下記のワーニングが表示されてしまいます。

Warning: Using a password on the command line interface can be insecure.

例えばユーザ名がrootでパスワードがmysqlの場合、下記のコマンドを実行すると表示されます。

mysql -uroot -pmysql

ワーニングを表示しなくするには、ユーザとパスワードを設定ファイルに書いて、mysqlコマンドのオプションに設定ファイルを指定するようにすると出なくなります。
名前はなんでもいいんですが、今回はmy.confという名前でファイルを作成します。

[client]
user = root
password = mysql

mysqlコマンドに--defaults-extra-fileというオプションがありますので、上記のファイル名を指定します。

mysql --defaults-extra-file=./my.conf

これでワーニングが出なくなります!

33
27
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
33
27