在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问

ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES)

其解决方法如下:
#service mysql stop
#mysqld_safe --user=mysql --skip-grant-tables --skip-networking&
#mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('root') whereUSER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
#service mysql start

如果想需要添加一个可以具有原创访问的mysql账号(需要进入mysql命令行下):

GRANT ALL PRIVILEGES ON *.* TO test@"%" IDENtiFIED BY "123456" WITHGRANT OPTION;

如果MySql5.6操作时报错:
You must SET PASSWORD before executing this statement

请执行下面的命令解决:
mysql>  SET PASSWORD = PASSWORD('root');

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页