Mysql ERROR 1045(28000):Access denied for user'root'@'localhost'の問題の解決

1389 ワード

解決策:
この問題は、パスワードを強制的に変更する必要があります.方法は次のとおりです.
/etc/init.d/mysql stop   (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables

別にSSH接続をつける
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit

pkill-KILL-t pts/0 ptsが0の**ユーザー(mysqld_safeを実行していたユーザーウィンドウ)を強制的に蹴り出すことができます
MySQL:/etc/initを正常に起動します.d/mysql start   (service mysqld start)
パスワードのクリア、ユーザーの文章のリセット:
First things first. Log in as root and stop the mysql daemon. 

sudo /etc/init.d/mysql stop 

Now lets start up the mysql daemon and skip the grant tables which store the passwords.

sudo mysqld_safe --skip-grant-tables&

(press Ctrl+C now to disown the process and start typing commands again)

You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

sudo mysql --user=root mysql

update user set Password=PASSWORD('new-password');
flush privileges;
exit; 

Now kill your running mysqld then restart it normally. 

sudo killall mysqld_safe&
(press Ctrl+C now to disown the process and start typing commands again)
/etc/init.d/mysql start

You should be good to go. Try not to forget your password again.