简体   繁体   中英

C# Remote MySQL - Access Denied For User

I cannot seem to connect to my remote MySQL database using C#. When I use MySQL Workbench I am able to connect successfully. But when I connect via connection string with C# I get:

Access denied for user 'username'@'myipaddress' to database 'drawingnumbers'

My connection string:

  connectionString = "server=" + server + ";user=" + uid + ";database=" + database + ";port=" + port + ";password=" + password + ";";

What I have tried:

  1. Added my local and external IP in the remote MySQL connection on cpanel
  2. Granting permission to my username to connect remotely with some SQL command I found online, access was denied (This is a shared server)
  3. Connected successfully using MySQL workbench with exact same parameters

are you using the username suffix in CPanel, because people miss that in most cases... for example if your CPanel username was abc then it should be abc_TheUsernameForMySQL

if not, try your CPanel username and Password, also you can use the ip address from the error to confirm you added the correct remote ip address to access the mysql server

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