当前位置:首页 > mysql > 正文内容

mysql登录报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

关中浪子1个月前 (03-21)mysql111
【腾讯云】2核2G4M云服务器新老同享99元/年,续费同价

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


对于出现拒绝访问root用户的解决方案
错误1045(28000):用户'root'@'localhost'(使用密码:YES)拒绝访问

首先解析此英文:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES);
解析的地方有两处:1.Access denied(拒绝访问);2.using password:NO/YES


一、出现access denied的原因有如下可能:

1)mysql的服务器停止:
  若MySQL已经没有启动,重启MySQL服务器:systemctl restart mysqld
2)用户的端口号或者IP导致:
  若用户的端口号与IP(3306/3307)不一致,打开my.ini文件进行编辑。全部编辑替换为: port=X
3)mysql的配置文件错误----my.ini等文件:
  my.ini文件误输入无效内容,不知道到何处。复制替换该文件;有人已经对my.ini文件进行解释以及注释:https://blog.csdn.net/lienfeng6/article/details/78140404
4)root用户的密码错误(后面解决)


二、出现 using password的原因如下:


不输入密码:

错误的密码:


解决方案:
vim /etc/my.cnf文件;
在[mysqld]后添加skip-grant-tables(登录时跳过权限检查)


重启MySQL服务:sudo systemctl restart mysqld

修改密码


登录mysql,输入mysql –uroot –p;直接回车(Enter)


输入:set password for ‘root’@‘localhost’=password(‘Admin123@qwe’);

如果报:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

输入:flush privileges;

再次输入:set password for ‘root’@‘localhost’=password(‘Admin123@qwe’);

为避免麻烦,再次设置远程访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'Admin123@qwe' WITH GRANT OPTION;

flush privileges;

退出:exit


再把my.ini的skip-grant-tables删除或者注释掉

重启MySQL:sudo systemctl restart mysqld


再次连接,成功


扫描二维码推送至手机访问。

版权声明:本文由码农翻生发布,如需转载请注明出处。

本文链接:https://lubojian.cn/post/269.html

分享给朋友:

相关文章

MySQL Index的使用

一、什么是索引?  索引用来快速地寻找那些具有特定值的记录,所有MySQL索引都以B-树的形式保存。如果没有索引,执行查询时MySQL必须从第一个记录开始扫描整个表的所有记录,直至找到符合要求的记录。表里面的记录数量越多,这个操作的代价就越...

windows mysql-installer-community-8.0.19.0.msi  社区版 windows service安装教程

windows mysql-installer-community-8.0.19.0.msi 社区版 windows service安装教程

一、下载MySQL登录MySQL官网下载MSI Installer:点击“Dnownload”点击“No thanks, just start my download.”二、安装MySQLStep1:选择安装类型根据个人需求,选择其中一个安...

You must configure either the server or JDBC driver (via the serverTimezone configuration property)

错误提示:Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception i...

mysql 8.0 和 mysql5.7配置文件修改sql_mode的方法

MySQL5.7:在MySQL配置文件中 my.ini    在[mysqld]标签里新增或修改:sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION重启MySQL。...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。