MySQL登錄報錯-ERROR 1045 (28000)

mysql -uroot -p

輸入設置的密碼

竟然報錯了!

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


密碼留空

還是錯誤!

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


於是重改密碼!

# /etc/init.d/mysql stop

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

mysql <-----登錄

mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; <----修改密碼

mysql> FLUSH PRIVILEGES;





假如忘記了登錄mysql的root用戶的密碼

#/etc/init.d/mysqld stop

手動啓動數據庫

#mysqld_safe --skip-grant-tables --skip-networking &

#mysql //登錄

(這種情況下,就不能使用grant來修改密碼,只能用update來修改密碼)

>update mysql.user set password=password('123456') where user='root'; //重新修改密碼

#/etc/init.d/mysqld restart //重啓數據庫

skip-grant-tables //跳過賦權表

skip-networking //跳過網絡



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章