Access denied for user ‘root’@’localhost’ (using password:YES)
首先停用mysql服務
service mysql stop
然後用此命令跳過網絡授權表
<span style="color: #ff0000;">mysqld_safe --user=mysql --skip-grant-tables --skip-networking &</span>
登錄mysql
Mysql –uroot –p
Mysql 密碼修改
mysql>use mysql;
mysql>update user set password=password('new_password') where user='用戶名';
mysql>flush privileges;
這種問題需要強行重新修改密碼,第二種方法如下:
/etc/init.d/mysql stop (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables
另外開個SSH連接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
pkill -KILL -t pts/0
可將pts為0的**用戶(之前運行mysqld_safe的用戶窗口)強制踢出
正常啟動
MySQL:/etc/init.d/mysql start (service mysqld start)