LoginSignup
1
1

More than 5 years have passed since last update.

MySQL5.7をインストールしたあと、好きなパスワードに一発で変更するワンライナー

Posted at
mysql --connect-expired-password -u root -p$(grep 'temporary password' /var/log/mysqld.log | cut -d' ' -f11) -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'パスワード';"

パスワードのポリシーがデフォルトでMEDIUMなので、パスワードが最低1つの数値文字を含み、1つの小文字および大文字を含み、1つの特殊文字を含む必要がある。

カンタンなパスワードにしたい場合は、事前に

mysql> SET GLOBAL validate_password_length=4;
mysql> SET GLOBAL validate_password_policy=LOW;

のように変更しておく必要がある。

mysql --connect-expired-password -u root -p$(grep 'temporary password' /var/log/mysqld.log | cut -d' ' -f11) -e "SET GLOBAL validate_password_length=4;SET GLOBAL validate_password_policy=LOW;ALTER USER 'root'@'localhost' IDENTIFIED BY 'パスワード';"

上記のコマンドで4文字以上であれば好きなパスワードにできる。

1
1
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
1
1