#author("2023-05-03T13:51:03+09:00","default:ryuichi","ryuichi")
#author("2023-05-03T13:51:15+09:00","default:ryuichi","ryuichi")
* rootユーザのパスワードをリセットする [#jb674727]

** 手順 [#s08a29e6]

- mysqldを停止する。
- mysqldを以下のようにオプション指定して起動する。(すると、パスワード無しでMySQLにログイン出来る。)
 shell> mysqld_safe --skip-grant-tables 
- パスワードを設定する。
-- MySQL5.6まで
 mysql> UPDATE mysql.user SET Password=PASSWORD('my_new_pass') WHERE User='root';
 mysql> FLUSH PRIVILEGES;
-- MySQL5.7以降
 mysql> UPDATE mysql.user SET authentication_string=password('my_new_pass') WHERE user = 'root'
-- MySQL8
 mysql> update user set authentication_string='new_my_pass' where User='root';
- mysqldを停止する。
- mysqldを通常起動する。

** 上で上手く行かない場合 [#t120c844]

 mysql> UPDATE user SET authentication_string=null WHERE User='root';

 mysql ALTER USER 'root'@'localhost' identified BY 'new_my_pass';
 mysql> ALTER USER 'root'@'localhost' identified BY 'new_my_pass';

** 参考 [#ga96de6e]
http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS