天天看點

mysql:1045 Access denied for user 'root'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

我把本地網站和伺服器上的網站都連接配接到伺服器mysql中的某個資料庫,幾次交替一觸登入後,資料庫開始報故障:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

然後linux背景也無法登入mysql

從網上試了幾個方法,都不行,隻有一個尚可:

# /etc/init.d/mysql stop
# cd to the mysql installation
# ./bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>