1

My connection string looks like this:

string server = "localhost";
string database = "stman";
string user = "logan";
string pass = "root";

string connStr = String.Format("Data Source={0};Initial Catalog={1}; User Id={2}; Password={3};", server, database, user, pass);

Given my understanding, this means MySql should be using 'logan'@'localhost' for the login, but it isn't.

It looks as though it's using 'logan'@<server's fully qualified name>:

Access denied for user 'logan'@'HP-PL-ML110.young.home'

I'm at a loss right now. SqlYog doesn't allow me to create a user with that hostname, my options for hostname are %, localhost or 127.0.0.1

Can anyone help me make sure that the website is using the specified username here? I have no idea what to look at to fix this

Ortund
  • 8,095
  • 18
  • 71
  • 139

2 Answers2

1

Joe's comment:

Have you tried disabling host name lookup, as in this question

Applying this didn't fix the issue but it did change the settings so that I could use the IP address in the connection string.

This does mean I had to create a new user (I found that, in Sqlyog, you can enter something different in the hostname field in user creation) and grant the new user the required permissions on the target database.

It's not exactly a solution, but it is a viable workaround that's got me back to a point where I can actually progress further in my development now.

Thanks Joe

Community
  • 1
  • 1
Ortund
  • 8,095
  • 18
  • 71
  • 139
0
string connStr = String.Format("Data Source={0};Initial Catalog={1}; User Id={2}; Password={4};", server, database, user, pass);

Should be

string connStr = String.Format("Server={0};Database={1};Uid={2};Pwd={4};", server, database, user, pass);
bansi
  • 55,591
  • 6
  • 41
  • 52