LoginSignup
1
2

More than 5 years have passed since last update.

MySQL ver5.7でrootのパスワードを忘れた場合の再設定方法

Posted at

MySQL ver5.7でrootのパスワードを忘れた場合の再設定方法

下記の方法でOK
1. MySQLを停止
2. MySQLをセーフモードで起動
3. mysql DBを使用
4. パスワード変更
5. FLUSH PRIVILEGES;

[root@vagrant-centos65 log]# service mysqld stop
[root@vagrant-centos65 log]# mysqld_safe --skip-grant-tables &
mysql> use mysql;
mysql> UPDATE mysql.user
    ->     SET authentication_string = PASSWORD('新パスワード'), password_expired = 'N'
    ->     WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;

公式サイト
https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

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