環境: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