MySQLのパスワード変更(緊急時)
状況
Ubuntu Server 8.10 MySQL 5.0
<!–more–>
作業内容
MySQLの停止
ルート権限にしてMysQLを停止させ、セーフモードからログイン出来るようにする。
$ sudo su # /etc/init.d/mysql stop # /usr/bin/mysqld_safe --user=root --skip-grant-tables &
MySQLでパスワード変更
アカウント"root"でMySQLにログインし、パスワードを変更する。
$ mysql -u root -p
mysql> use mysql;
mysql> show tables;
mysql> select host, User, Password from user;
mysql> update user set password=password('new password') where user='root';
mysql> flush privileges;
mysql> exit
MySQLの再起動
# /etc/init.d/mysql stop # /etc/init.d/mysql start