简体   繁体   中英

I got this error message : Access denied for user (Using password YES)

I have a question.

I just created an app using WPF. and trying to connect the database to retrieve the data. for the first time, I try to use the local database at my computer. using XAMPP and mysql.

Using the XAMPP, I can retrieve the data normally. Now I want to use the database at my website. But when I run the app, it fails and shows me this error message:

Access denied for user '[my user]' (using password: YES)

FYI, I already created a username and password. I also granted all the privileges using the wizard, but still won't work.

Here is my connection string:

MySqlConnection conn = new MySqlConnection("Server=[IP Address]; Database=[database name];Uid=[user id];Pwd=[password];");

Is there any mistake in my connection string?

MySQL credentials take into account the host name of the computer making the request. For example requests made on the server might look like user@localhost. A call from a computer named client would look like user@client. Each of these need there own user account, unless you wildcard the hostname portion of the login. I would guess that the account you were using is hostname specific, so you will need to wildcard the host name or make an entry for the account it is saying is not authorised.

This link talks a bit about it.

http://dev.mysql.com/doc/refman/5.6/en/account-names.html

finally i found the answer..

The answer is you just need to add server '%' at your hosting. after add '%', you can add another IP address for .NET app to access the database.

in .NET, change the server with the IP address that you add from your hosting. thanks.

Like Philip Tinney says you can wildcard the hostname portion. I used this on our dev-server (not recommended for production servers):

update mysql.user set host = '%' where host='localhost';

Then I had to restart the server to make MySQL use it (propably I could just have restarted the MySQL service).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM