MySQL登入報錯-ERROR 1045 (28000)

來源:互聯網
上載者:User

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 //跳過網路



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.