解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)
一、问题
有时候我们登录mysql输入密码的时候,会出现这种情况
mysql -u root -p
enter password > '密码'
错误:error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
或者:错误:error 1045 (28000): access denied for user 'root'@'localhost' (using password: no)
二、解决办法
修改my.in/my.cnf配置文件
进入mysql安装目录
编辑my.ini
在[mysqld]下添加skip-grant-tables,保存即可。
使用管理员身份打开命令行
①重启mysql:
1、net stop mysql 2、net start mysql
②进入mysql,登录
mysql -u root -p
不用输入密码,直接回车(出现enter password 也一样直接回车,即可登陆成功)
③输入use mysql,修改root的密码:
update user set authentication_string=password('新密码') where user='root';
flush privileges;
④退出:
quit;
⑤再次重启mysql:
1、net stop mysql 2、net start mysql
⑥测试是否成功就是是否登陆成功咯。
mysql -u root -p
enter password>'新密码'
就不会出错,可以登录啦!!!
(另外一种情况就是,,你密码输入错误了,如果是初始化后第一次登录,出现这种情况的话,很大概率就是密码错误,初始化后的密码要认真查看,可能会因为空格、小数点等符号输错)
以上就是解决mysql:error 1045 (28000): access denied for user 'root'@'localhost' (using password: no/yes)的详细内容,更多关于error 1045 (28000): access denied for user 'root'@'localhost' (using password: no/yes) 的资料请关注其它相关文章!
推荐阅读
-
MySQL密码正确却无法本地登录-1045 Access denied for user 'root'@'localhost' (using password:YES
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwor
-
java访问数据库被拒绝,不能连接数据库ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法
-
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: YES)实用解决方案
-
ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)
-
Access denied for user 'root'@'localhost' (using password:YES) Mysql5.7
-
ERROR 1045: Access denied for user: root@localhost (Using password: NO)
-
Eclipse使用jdbc连接MySql数据库报:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)