Access denied for user 'root'@'localhost' (using password:YES) 解决方案
来源:互联网 发布:淘宝刷在线人数 编辑:程序博客网 时间:2024/04/19 21:23
相信这个问题大部分人都遇到过,至少我遇到过三次了,而且每次原因都不一样,前段时间同学也遇到这个问题,问我怎么解决,我把我的解决思路都说了一遍,发现还不行,最后居然是另外一个原因。。。哎,说多了都是泪,总结如下:
(注:本文都建立在数据库能正常使用,但是程序无法连接数据库的基础上,如果在doc窗口或者用其他mysql图形界面都连接不上,请自补mysql的基础知识吧)
1.基于官方说法(http://dev.mysql.com/doc/refman/5.5/en/access-denied.html)
If you have access problems with a Perl, PHP, Python, or ODBC program,try to connect to the server withmysql -u user_namedb_nameormysql -u user_name-pyour_passdb_name. If you are able to connect using the mysql client, the problem lies with your program, not with the access privileges.There is no space between-pand the password大概意思就是,如果能用mysql命令行进入mysql,就说明mysql安装没问题,是你程序的问题,没有连接权限(这里后面细说)。这里要说明一点的就是,非常重要,就是最后一句话,不要有空格!我就是吃了这个亏啊,在jabc.properties里面配置username和password时,因为换行的原因,里面有空格,说白了还是用户名和密码出错。如下
jdbc.username=root jdbc.password=123456
root和123456后面都有空格,这个真是肉眼发现不了啊。。。。所以删掉空格就好了
2.用户没有权限(骗自己?参考)
其实,这一点也是网上看别人这么说的,自己没用过。但是我想,如果像我前面第一点提到的,你能在命令行模式下用这个用户名和密码进入mysql的话,那肯定有权限了啊,干嘛还要赋予权限?。。。所以仅供参考。。。
CREATE USER 'root'@'localhost' IDENTIFIED BY '你的密码';GRANT ALL PRIVILEGES ON *.* TO root@'localhost';
3.mysql和驱动jar版本冲突
这个是我同学出现的问题,他前面的问题都没有,后来我们发现,他安装的mysql是5.7,但是用的驱动jar(mysql-connector)是5.1.3(是我发给他的,怪我咯),好像程序里面一直连不上mysql,然后就没有然后了,就卸载了5.7的mysql,重新安装了5.0的mysql...(安装了还是在重启后才起效的),所以这个是个特例。。。
以上仅供参考哈。。。大神请轻喷,欢迎探讨
2 0
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- access denied for user 'root'@'localhost'(using password:YES)解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- Access denied for user 'root'@'localhost' (using password: YES)解决方案
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- #1045 - Access denied for user 'root'@'localhost' (using password: YES)
- Access denied for user 'root'@'localhost' (using password: YES) 问题解决
- 解决'Access denied for user 'root'@'localhost' (using password: YES)'
- access denied for user 'root'@'localhost' using password yes
- access denied for user 'root'@'localhost' using password yes
- 自定义多层级连网页右键
- js获取屏幕以及网页等宽度和高度
- 在宏定义中如何使用一个外部文件的的值来决定宏定义
- Struts2的灵魂——Interceptor
- 多线程编程1-----ThreadLocal
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- css中top和margin-top的区别
- 九尾猫的故事
- UVA - 1156 Pixel Shuffle (置换+模拟)
- Linux 2440 LCD 控制器
- EditText知识
- android后台进程数目限制
- 游戏开发精英交流招聘
- usb-host一步一步学(一)安卓在usb-host模式下列出当前连接的usb设备