免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 114134 | 回复: 26
打印 上一主题 下一主题

求助数据库连接:ERROR 1045 (28000): Access denied for user (using password: YES) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-29 20:09 |只看该作者 |倒序浏览
通过root用户,我添加了用户xcj。
再通过root登录后,查看mysql表,部分如下:
+------+-------------------+
| user | host              |
+------+-------------------+
| xcj  | %                 |
|      | localhost         |
|
+------+-------------------+。

但在本地利用密码登录,提示错误:
ERROR 1045 (28000): Access denied for user 'xcj'@'localhost' (using password: YES)
在网上找到一些办法仍不能解决问题。

同时通过xcj更不能在远程登录?

望高手指点,不胜感激!

论坛徽章:
0
2 [报告]
发表于 2005-12-02 09:14 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2006-03-27 16:33 |只看该作者
我现在也遇到同样的困惑。
我已经不是第一次遇到这样的问题了。

[jiaofan@jiaofan Discuz]$ mysql test -u Discuz -p
Enter password:
ERROR 1045 (28000): Access denied for user 'Discuz'@'localhost' (using password: YES)
[jiaofan@jiaofan Discuz]$
mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> set password for  Discuz=old_password("1234");
Query OK, 0 rows affected (0.00 sec)

再次登陆,依然失败
[jiaofan@jiaofan Discuz]$ mysql test -u Discuz -p
Enter password:
ERROR 1045 (28000): Access denied for user 'Discuz'@'localhost' (using password: YES)
[jiaofan@jiaofan Discuz]$

论坛徽章:
0
4 [报告]
发表于 2006-03-27 23:21 |只看该作者
原帖由 xcj_101 于 2005-11-29 20:09 发表
通过root用户,我添加了用户xcj。
再通过root登录后,查看mysql表,部分如下:
+------+-------------------+
| user | host              |
+------+-------------------+
| xcj  | %                 |
| ...


删除那条 user 为 空、host 为 localhost 的记录。你新添加的记录被它匹配了,根本匹配不到。

论坛徽章:
0
5 [报告]
发表于 2007-03-21 11:15 |只看该作者
我这边user不为空,一直报错1045。。
mysql.user表记录如下:
+-----------------------+----------+-------------------------------------------+
| host                  | user     | password                                  |
+-----------------------+----------+-------------------------------------------+
| localhost             | root     |                                           |
| localhost.localdomain | root     |                                           |
| %                     | root     |                                           |
| localhost             | jirauser | *63AD73E83AF95C5C04800F78E383EA191242CC8F |
| %                     | jirauser | *63AD73E83AF95C5C04800F78E383EA191242CC8F |
+-----------------------+----------+-------------------------------------------+
5 rows in set (0.00 sec)

jirauser通过远程可以连接,在localhost就是无法登录。
#mysql -u jirauser -pjirauser
ERROR 1045 (28000): Access denied for user 'jirauser'@'localhost' (using password: YES)

论坛徽章:
0
6 [报告]
发表于 2008-05-14 13:00 |只看该作者
后面需要加-h ServerIPAddr
如:
mysql -u xx -p -h 192.168.1.1然后输入密码,就OK了

[ 本帖最后由 pressman 于 2008-5-14 13:01 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2008-05-14 14:28 |只看该作者
这仅仅是访问权限不够
ERROR 1045 (28000): Access denied for user 'xcj'@'localhost' (using password: YES)


#新加用户服务xcj,新加的用户不能马上生效
mysql> grant all on *.* to xcj@'%' identified by "xcj_passwd";
Query OK, 0 rows affected (0.04 sec)

#生效新加用户xcj权限
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)


[root@openfire pdf_spider]# mysql -uxcj -p'xcj_passwd'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4593
Server version: 5.0.45-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

#若是还不生效,就见鬼了


[ 本帖最后由 todayhero 于 2008-5-14 14:30 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2008-05-14 17:12 |只看该作者
增加用户后,要记得刷新或重启服务器,另口令要用password函数

论坛徽章:
0
9 [报告]
发表于 2008-08-16 17:59 |只看该作者
照七楼的观点,我想我撞见了
我的情况是 grant 跟本就不生效
。。。

论坛徽章:
0
10 [报告]
发表于 2008-10-03 12:47 |只看该作者
重改密码!

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password:

mysql>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP