Mysql登錄出錯 user root@localhost(using password:NO)

環境:redhat 5.7 安裝了mysql 5.0
安裝完mysql之後啓動成功,但是使用mysql -uroot -p登錄是,密碼錯誤,確定沒有設置過密碼
出錯提示:Access denied for user 'root'@'localhost' (using password : No)
解決辦法如下:

1.先關閉mysql服務
xiaopeng# /etc/init.d/mysqld stop
2.輸入操作命令
xiaopeng# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3.連接mysql
xiaopeng# mysql -uroot mysql
mysql> update user set Password=PASSWORD('newpassword') where USER='root';
mysql> flush PRIVILEGES;
mysql> quit
4.重啓mysql服務
xiaopeng# /etc/init.d/mysqld restart
xiaopeng# mysql -uroot -p
Enter password:<newpassword>

更多資源請訪問www.arppinging.com

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