Access denied for user ‘root’@’localhost’ (using password:YES)
首先停用mysql服务
service mysql stop
然后用此命令跳过网络授权表 mysqld_safe --user=mysql --skip-grant-tables --skip-networking
登录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)