MySQL密码正确却无法本地登录-1045
作者:< Keep Learning > 时间:2024-01-24 12:04:04
MySQL密码正确却无法本地登录-1045 Access denied for user 'root'@'localhost' (using password:YES
MySQL密码正确却无法本地登录
报错如下:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
解决方法:
1、在启动mysql的参数中加入跳过密码问题方式,如下:
vim /etc/my.cnf
并在[mysql]下面加上skip-grant-tables,
这个用于跳过密码问题,但是这并不能彻底解决。
2、重启mysql服务
本人用的是Linux系统的Mysql,语句如下:
查看端口号:
ps aux|grep mysqld
查看状态:
systemctl status mysqld
重启mysql服务
systemctl restart mysqld
尝试连接:
mysql -uroot -p123456
输入密码,刚才已经设置跳过密码了可忽略
操作步骤如下:
[root@localhost ~]# mysql -uroot -p123456
mysql> use mysql
Database changed
mysql> select user,host,password from user where user='root';
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | % | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | localhost.localdomain | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | 127.0.0.1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | ::1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
+------+-----------------------+-------------------------------------------+
4 rows in set (0.02 sec)
mysql> update user set host='localhost' where user='root' and host='%';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql> quit
Bye
OK,退出mysql,重启mysql就解决问题了
前后对比一下:
[root@localhost ~]# mysql -uroot -p
mysql> use mysql;
Database changed
mysql> select user,host,password from user where user='root';
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | localhost.localdomain | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | 127.0.0.1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | ::1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
+------+-----------------------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
OK!
总结
以上所述是小编给大家介绍的MySQL密码正确却无法本地登录-1045 Access denied for user ''root''@''localhost'' (using password:YES网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
来源:https://www.cnblogs.com/hxun/archive/2019/12/20/12072850.html
标签:mysql,密码,正确,登录
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
mysql 5.1版本修改密码及远程登录mysql数据库的方法
2024-01-17 15:38:02
SqlServer 2005 简单的全文检索
2024-01-18 05:00:31
在python中bool函数的取值方法
2021-10-06 00:47:37
SQL Server 2005 安装遇到的错误提示和解决方法
2024-01-20 13:19:15
![](https://img.aspxhome.com/file/2023/3/75643_0s.jpg)
php strftime函数的详细用法
2023-06-07 19:09:37
python实现二维插值的三维显示
2022-05-28 14:17:58
![](https://img.aspxhome.com/file/2023/6/121476_0s.jpg)
【Python】Python的urllib模块、urllib2模块批量进行网页下载文件
2021-04-26 18:19:14
![](https://img.aspxhome.com/file/2023/6/133336_0s.jpg)
Pandas中的unique()和nunique()区别详解
2022-02-06 21:51:05
![](https://img.aspxhome.com/file/2023/2/135052_0s.png)
python绘制铅球的运行轨迹代码分享
2021-06-12 06:39:03
![](https://img.aspxhome.com/file/2023/3/84123_0s.jpg)
博客使用标签是迟早的事
2008-10-31 12:55:00
使用Python脚本实现批量网站存活检测遇到问题及解决方法
2022-04-12 00:50:03
python实现坦克大战
2021-01-09 19:18:53
![](https://img.aspxhome.com/file/2023/6/107946_0s.gif)
压缩包密码破解示例分享(类似典破解)
2022-10-17 17:03:37
vue判断input输入内容全是空格的方法
2024-04-09 10:48:01
python中注释用法简单示例
2022-10-24 05:04:09
![](https://img.aspxhome.com/file/2023/8/111918_0s.png)
关于Matplotlib绘制动态实时曲线的方法改进指南
2021-03-17 23:48:10
![](https://img.aspxhome.com/file/2023/6/115046_0s.png)
Python3.X 线程中信号量的使用方法示例
2022-06-12 12:07:13
![](https://img.aspxhome.com/file/2023/3/107243_0s.png)
用css和js实现firefox和IE支持局部打印
2008-05-23 13:04:00
基于Python-Pycharm实现的猴子摘桃小游戏(源代码)
2023-07-07 06:31:22
![](https://img.aspxhome.com/file/2023/5/60705_0s.png)
linux下安装apache与php;Apache+PHP+MySQL配置攻略
2023-11-14 15:43:46