问题
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: Access denied for user 'altjenb'@'localhost' (using password: YES)
this is the connection string
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';
but still is the same error.
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?
Im trying to connect unity3d 5 with mysql db
回答1:
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)
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 |
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;");
both connections will work
But user 2 only has access to 127.0.0.1
so:
new MySqlConnection("Server=localhost; port= 3306; Database=battlehunt_db; UserId=user2; Password=egrgeaf;");
will fail because it's trying to connect to 'localhost'
and
new MySqlConnection("Server=127.0.0.1; port= 3306; Database=battlehunt_db; UserId=user2; Password=whatever;");
will succeed.
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.
hope this help
回答2:
The problem is not with the code. but with the connector, the version of connector I use is not updated with mysql8.
来源:https://stackoverflow.com/questions/41609572/mysqlexception-access-denied-for-user-altjenblocalhost-using-password-ye