あるサーバのMySQLのrootパスワードを失念してしまった。
マニュアルをあさってみたけど、プロセスをkillしてとか書いてあるし、
あんで、killなんだろう。。。と思いながらも、いろいろなサイトを参考に
行った手順を整理しておきます。
■サービスを停止
[root@www mysql]# service mysqld stop
Stopping MySQL: [ OK ]
プロセスがないことを確認
[root@www mysql]# ps -e | grep mysql
[root@www mysql]# ls /usr/libexec/mysql
mysqld mysqlmanager
--skip-grant-tablesオプションをつけてmysqlデーモンを起動する
[root@www mysql]# su mysql -c '/usr/libexec/mysqld --skip-grant-tables'
別のシェルから接続
[root@www ~]# mysql mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.50 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select * from user;
初期化します
mysql> update user set Password=null where Host='localhost' and User='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> exit
Bye
--skip-grant-tablesオプションをつけて起動していたデーモンを終了する
デーモン起動
root@www mysql]# service mysqld start
Starting MySQL: [ OK ]
パスワード設定
[root@www ~]# mysqladmin --user=root password 新しいパスワード設定
マニュアルをあさってみたけど、プロセスをkillしてとか書いてあるし、
あんで、killなんだろう。。。と思いながらも、いろいろなサイトを参考に
行った手順を整理しておきます。
■サービスを停止
[root@www mysql]# service mysqld stop
Stopping MySQL: [ OK ]
プロセスがないことを確認
[root@www mysql]# ps -e | grep mysql
[root@www mysql]# ls /usr/libexec/mysql
mysqld mysqlmanager
--skip-grant-tablesオプションをつけてmysqlデーモンを起動する
[root@www mysql]# su mysql -c '/usr/libexec/mysqld --skip-grant-tables'
別のシェルから接続
[root@www ~]# mysql mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.50 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select * from user;
初期化します
mysql> update user set Password=null where Host='localhost' and User='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> exit
Bye
--skip-grant-tablesオプションをつけて起動していたデーモンを終了する
デーモン起動
root@www mysql]# service mysqld start
Starting MySQL: [ OK ]
パスワード設定
[root@www ~]# mysqladmin --user=root password 新しいパスワード設定
コメントする