SQL サーバーの root パスワードを回復する方法を学ぶステップバイステップのチュートリアル。
サーバの中で最も重要なユーザー MySQL 間違いなくユーザーです」root」。 このユーザーはすべてを持っています 管理者権限 (データベース用MySQL databases).
MySQL root ユーザーのパスワードが分からなくなった場合は、いくつかの簡単な手順に従ってこのパスワードをリセットする必要があります。
チュートリアルはサーバー用に作成されています MySQL オペレーティング システムにインストールされている CentOSただし、プロセスは他のディストリビューションでも同じです Linux.
SQL サーバーの root ユーザーのパスワードを回復する方法
SQL サーバーの root ユーザーのパスワードを回復する最も簡単な方法は、次のとおりです。 SSH (Secure Shell).
1. ユーザー「」でログインします。root」を MySQL サーバーが存在するシステムに送信します。 (MySQL サーバーではなく、システムの root ユーザー)。 コンソールから直接ログインするか、接続経由でリモートからログインします ssh (で パテ システムから Windows).
2。 プロセス/ MySQLのを停止します。
service mysqld stop
または
/etc/init.d/mysqld stop
結果は次のようになります。
Stopping MySQL: [ OK ]
3. MySQL サーバーをオプション「」で起動します。--skip-grant-tables
」。 MySQLサーバーの起動/daemon パスワードなしで処理します。
mysqld_safe --skip-grant-tables &
上記のコマンドラインの後の出力は次のとおりです。
[1] 3041
[root@server ~]# Starting mysqld daemon with databases from /var/lib/mysql
4. ユーザー「」で mysql サーバーに接続します。root"、次のコマンドを使用します。
mysql -u root
コマンドの結果:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql>
5. mysql データベースを選択し、ユーザーの新しいパスワードを設定します。root"
use mysql;
update user set password=PASSWORD("New_Password") where User='root';
flush privileges;
quit
上記のコマンドの結果:
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
mysql> update user set password=PASSWORD("123456") where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@server ~]#
6.サービス/サーバーを停止して再起動します MySQL
service mysqld stop
service mysqld start
結果:
Starting MySQL: [ OK ]
下の写真はすべてを示しています パスワードのリセットプロセス ユーザーの「rootサーバーの「」 MySQL.
今、私たちは、(経由のMySQLに接続することができます phpMyAdminの 例) 「root」ユーザーで、上で設定した新しいパスワードを使用します。
チュートリアルテスト CentOS 5.6 MySQL Ver 14.12 Distrib 5.0.77、redhat用-linux-readline 686を使用するgnu(i5.1)。