カテゴリー : mysql

MYSQLのrootパスワードを忘れた

rootになります。

$ su -
パスワード(P):

MYSQLを終了させます。

# killall mysqld

権限テーブルを無視する形でmysqlを起動させます。
# /usr/bin/mysqld_safe –user=root –skip-grant-tables &

mysqlクライアントからパスワードを変更を変更します。

# mysql -u root

mysql> update user set password=password(’新しいパスワード’) where user=’root’;
Query OK, 1 rows affected (0.05 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

MYSQLを再起動します。

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

新しいパスワードでログインできるか確認します。

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25138 to server version: 5.0.27

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> exit
Bye

これでOK!