brocky34
brocky34

Reputation: 178

Access denied for user 'root'@'%' (using password: YES) but logged in as root

I'm aware there are similar questions all over the web, but I can't find anything for this particular issue. I have C# experience, but am pretty new to MySQL, so perhaps there's something I'm not understanding. I'm trying to make a simple select in C# from a MySQL table:

            string server = "192.168.2.6";
            string database = "productintegration";
            string uid = "root";
            string password = "Password1";
            string connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

            MySqlConnection connection = new MySqlConnection(connectionString);

            string query = "select * from tcdidataimport";

            connection.Open();
            MySqlCommand cmd = new MySqlCommand(query, connection);
            MySqlDataReader dataReader = cmd.ExecuteReader();
            DataTable dt = new DataTable();

            if (dataReader.HasRows)
            {
                dt.Load(dataReader);
            }
            connection.Close();

And I get the following exception:

Authentication to host '192.168.2.6' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'JUSTINSPERSONAL' (using password: YES)

Seems simple enough... Except that I'm already connecting to that server (via MySQL Workbench) using that exact login.

Here is show grants;

enter image description here

Which seems to me that I should be able to log in using root at whatever I want? When I tried to create another user (CDISelector@'%') and grant privileges I got a similar error:

enter image description here

But I'm logged in as root? Am I missing something here? Finally, here's the results of select user(), current_user();

enter image description here

JUSTINSPERSONAL is my PC, 192.168.2.6 is the MySQL machine's IP. Not sure what I'm missing here but this all seems a little strange.

Upvotes: 1

Views: 4048

Answers (1)

brocky34
brocky34

Reputation: 178

And it turns out I had the password incorrect. Ha.

Upvotes: 4

Related Questions