MySqlException:用户“altjenb"@“localhost"的访问被拒绝(使用密码:YES) [英] MySqlException: Access denied for user 'altjenb'@'localhost' (using password: YES)

查看:46
本文介绍了MySqlException:用户“altjenb"@“localhost"的访问被拒绝(使用密码:YES)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么我会得到这个,用户,altjenb 在 mysql 数据库中有完全访问权限,但我仍然收到同样的错误.我尝试在 mysql8.db4free.net 和 db4free.net 上使用在线数据库并得到相同的错误.在 localhost (xampp) 中尝试过,仍然是同样的错误..

I dont know why am I getting this, user, altjenb has full access in the mysql db but I still keep getting the same error. I tried to use online db at mysql8.db4free.net and db4free.net and got the same error. tried in localhost (xampp) and still the same error..

MySqlException: 用户 'altjenb'@'localhost' 的访问被拒绝(使用密码:是)

MySqlException: Access denied for user 'altjenb'@'localhost' (using password: YES)

这是连接字符串

MySqlConnection connectionstring = new MySqlConnection("Server=localhost; port= 3306; Database=battlehunt_db; UserId=altjenb; Password=egrgeaf;");

我手动授予用户完全访问权限.但还是什么都没有我试图通过

I manually granted full access to the user. but still nothing, I tried to give access with

GRANT ALL PRIVILEGES ON * battlehunt_db. * TO 'altjenb'@'localhost';

但还是一样的错误.

但是当我将用户 ID 更改为 root 并且没有密码时.它连接到数据库 .. 看起来它没有收到用户名.. 我尝试添加一个未在(例如 egwetr)中注册的随机用户名,但它仍然显示相同的错误..

but when I change the userID to root and no password. it connects to the db.. it looks like it doesnt receive the user name.. I tried to add a random user name who is not registered in (eg. egwetr) and still it showed the same error..

我该如何解决这个问题?

how can I fix this?

我正在尝试将 unity3d 5 与 mysql db 连接

Im trying to connect unity3d 5 with mysql db

推荐答案

好的,解释我对这个问题的评论.

Ok, Explaining my comment on the question.

假设该用户的密码是正确的错误信息:

Assuming that the password for that user is correct the Error message:

MySqlException: Access denied for user 'altjenb'@'localhost' (using password: YES)

这可能意味着用户没有连接到服务器'localhost'的权限

It can mean that the user does not have permision to connect to the server 'localhost'

在用户表中,您可以看到哪些主机具有权限:

In the user table you can see to what host has permission:

---------------------------
   user     |    host     |
---------------------------
user1       |   localhost |
user1       |   127.0.0.1 |
user2       |   127.0.0.1 |

在这个例子中,user1 可以连接到 localhost 和 127.0.0.1 所以:

in this example, user1 can connect to localhost and 127.0.0.1 so:

new MySqlConnection("Server=localhost; port= 3306; Database=battlehunt_db; UserId=user1; Password=egrgeaf;");
new MySqlConnection("Server=127.0.0.1; port= 3306; Database=battlehunt_db; UserId=user1; Password=whatever;");

两个连接都有效

但用户 2 只能访问 127.0.0.1

But user 2 only has access to 127.0.0.1

所以:

new MySqlConnection("Server=localhost; port= 3306; Database=battlehunt_db; UserId=user2; Password=egrgeaf;");

会失败,因为它试图连接到本地主机"

will fail because it's trying to connect to 'localhost'

new MySqlConnection("Server=127.0.0.1; port= 3306; Database=battlehunt_db; UserId=user2; Password=whatever;");

会成功.

在Mysql的用户表中查看哪个主机可以访问用户'altjenb',如果'altjenb'没有主机'localhost',您可以添加它或将连接字符串更改为用户拥有的主机之一.

Check in the user table of Mysql to what host has access the user 'altjenb', if 'altjenb' does not have the host 'localhost' you can add it or change the connection string to one of the hosts the user has.

希望对您有所帮助

这篇关于MySqlException:用户“altjenb"@“localhost"的访问被拒绝(使用密码:YES)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆