60
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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パスワード');

以上で再設定完了。

60
68
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
60
68

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?