Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
68
Help us understand the problem. What is going on with this article?

More than 5 years have passed since last update.

@Wollest

MySQLでrootパスワードを忘れた時のリセット方法

MySQLのrootパスワードを忘れたときの対処法

まずroot権限に。

# su -
password:

次にmysqlをkillする。

# killall mysqld

セーフモードでmysqlにログイン

# /usr/local/mysql/bin/safe_mysqld --user=root --skip-grant-tables & mysql mysql

もしくは

# /usr/bin/mysqld_safe --user=root --skip-grant-tables & mysql mysql

これでmysqlにログインできるのでパスワードを初期化

mysql> update user set Password=null where Host='localhost' and User='root';
mysql> exit

次にセーフモードではなく普通の状態でmysqlを再起動

# /etc/rc.d/init.d/mysqld restart

mysqlにroot(パスワードなし)でログインしてにパスワードを再設定

# mysql -u root
mysql> set password for root@localhost=password('rootパスワード');

以上で再設定完了。

68
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
68
Help us understand the problem. What is going on with this article?