アーッ!!
アーッ!
アーッ
フキフキ・・・。ッポイッ。
ふぅ~・・・。
あ、どうもこんばんは。
夕方に予約公開してるけど、記事書いてるのは昨日の夜です。
今さっき何をしてたかは、お察しください。
さて、Linuxサーバを久しぶりに立ち上げたのですが、MySQLのパスワード忘れました・・・。
なので。パスワードの再設定をしました。
以下、赤字は入力項目
--------------------------------------------------------------
[ucchanx@dip ~]$ su -
パスワード:
[root@dip ~]# killall mysqld
--------------------------------------------------------------
まず、ルートでログインして、MySQLを終了しました。
今回は、強制終了しましたが、後で「普通に終了したらいい」ことに気づきました。
--------------------------------------------------------------
[root@dip ~]# mysqld_safe --skip-grant-tables
131124 16:38:15 mysqld_safe Logging to '/usr/local/mysql/data/dip.ucchanx.net.err'.
131124 16:38:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
--------------------------------------------------------------
そして、MySQLをセーフモードで起動しました。
ここで、端末が操作を受け付けなくなるので、もう一つ端末を起動します。
そして、セーフモードで起動したMySQLにrootでログインします。
--------------------------------------------------------------
[ucchanx@dip ~]$ mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.27 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
--------------------------------------------------------------
MySQLに接続できましたので、パスワードを設定します。
--------------------------------------------------------------
mysql> update user set password=PASSWORD('root') where user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
--------------------------------------------------------------
そして、なんか更新します。
--------------------------------------------------------------
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
--------------------------------------------------------------
「FLUSH」はMySQLの内部キャッシュを削除するコマンドで、「PRIVILEGES」は権限を再読み込みするオプションです。
これで、再起動しておしまい。
今回、パスワードをユーザー名と同じにしましたが、外部に接続してないので、まぁいいや。
--------------------------------------------------------------
[ucchanx@dip ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
--------------------------------------------------------------
ちゃんとログインできました。
アーッ!
アーッ
フキフキ・・・。ッポイッ。
ふぅ~・・・。
あ、どうもこんばんは。
夕方に予約公開してるけど、記事書いてるのは昨日の夜です。
今さっき何をしてたかは、お察しください。
さて、Linuxサーバを久しぶりに立ち上げたのですが、MySQLのパスワード忘れました・・・。
なので。パスワードの再設定をしました。
以下、赤字は入力項目
--------------------------------------------------------------
[ucchanx@dip ~]$ su -
パスワード:
[root@dip ~]# killall mysqld
--------------------------------------------------------------
まず、ルートでログインして、MySQLを終了しました。
今回は、強制終了しましたが、後で「普通に終了したらいい」ことに気づきました。
--------------------------------------------------------------
[root@dip ~]# mysqld_safe --skip-grant-tables
131124 16:38:15 mysqld_safe Logging to '/usr/local/mysql/data/dip.ucchanx.net.err'.
131124 16:38:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
--------------------------------------------------------------
そして、MySQLをセーフモードで起動しました。
ここで、端末が操作を受け付けなくなるので、もう一つ端末を起動します。
そして、セーフモードで起動したMySQLにrootでログインします。
--------------------------------------------------------------
[ucchanx@dip ~]$ mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.27 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
--------------------------------------------------------------
MySQLに接続できましたので、パスワードを設定します。
--------------------------------------------------------------
mysql> update user set password=PASSWORD('root') where user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
--------------------------------------------------------------
そして、なんか更新します。
--------------------------------------------------------------
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
--------------------------------------------------------------
「FLUSH」はMySQLの内部キャッシュを削除するコマンドで、「PRIVILEGES」は権限を再読み込みするオプションです。
これで、再起動しておしまい。
今回、パスワードをユーザー名と同じにしましたが、外部に接続してないので、まぁいいや。
--------------------------------------------------------------
[ucchanx@dip ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
--------------------------------------------------------------
ちゃんとログインできました。