MYSQLリセットrootパスワード
1.MYSQLサービスを停止する;
UbuntuまたはDebianで
または
CentOS,Fedora,RHELで:
または
2.安全モードに入る
PS:最後の
このような情報が表示されるかもしれません.
これらの類似情報が表示されたら、
見つかったら
3.空のパスワードでログイン
4.
このような情報が表示されます.
5.パスワードの再設定
これらを見ることができます
6.権限の再設定
以下におなじみのヒントがあれば、基本的に成功します.
7.終了
8.MYSQLの再起動
UbuntuまたはDebianで
そして
CentOS,Fedora,RHELで:
そして
9.再ログイン
設定したパスワードを入力します.DONE
Happy Hacking
UbuntuまたはDebianで
sudo service mysql stop
または
sudo /etc/init.d/mysql stop
CentOS,Fedora,RHELで:
sudo service mysqld stop
または
sudo /etc/init.d/mysqld stop
2.安全モードに入る
sudo mysqld_safe --skip-grant-tables &
PS:最後の
&
号がありますこのような情報が表示されるかもしれません.
mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
mysqld_safe Logging to '/var/log/mysql/error.log'.
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
これらの類似情報が表示されたら、
CTRL+C
を押して終了し、次のステップに進みます.NOTES: , , ,
mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
mysqld_safe Logging to '/var/log/mysql/error.log'.
mysqld_safe A mysqld process already exists
mysql
ps uaxww | grep -i mysql
見つかったら
kill
でプロセスを終了し、もう一度やり直します.3.空のパスワードでログイン
mysql -u root
4.
mysql
データベースの使用use mysql;
このような情報が表示されます.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
5.パスワードの再設定
update user set password=PASSWORD("yournewpassword") where User='root';
yournewpassword
あなたが設定したパスワードに置き換えますこれらを見ることができます
mysql> update user set password=PASSWORD("yournewpassword") where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
6.権限の再設定
flush privileges;
以下におなじみのヒントがあれば、基本的に成功します.
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
7.終了
quit
8.MYSQLの再起動
UbuntuまたはDebianで
sudo /etc/init.d/mysql stop
そして
sudo /etc/init.d/mysql start
CentOS,Fedora,RHELで:
sudo /etc/init.d/mysqld stop
そして
sudo /etc/init.d/mysqld start
9.再ログイン
mysql -u root -p
設定したパスワードを入力します.DONE
Happy Hacking