Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication failed using method mysql_native_password

Trying to connect to MySQL on my web host, using Connector/Net C#/WinForms in Visual Studio 2012 Update 3, but getting the below error message:

Authentication to host '1.1.1.1' for user '[email protected]' using method 'mysql_native_password' failed with message: Access denied for user '[email protected]'@'2.2.2.2' (using password: YES)

string connectionString = "SERVER=1.1.1.1;PORT=3306;DATABASE=databaseName;[email protected];PASSWORD=mypassword;";

MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();

I am connecting remotely, have whitelisted my IP (and even temporary whitelisted all (%) to test), triple checked the username and password and IP.

I originally tried the username without the domain ( username rather than [email protected]) but it gave me the below error:

Authentication with old password no longer supported, use 4.1 style passwords.

Any assistance would be much appreciated, thanks!

like image 479
Badger Sharescott Avatar asked Jul 15 '13 06:07

Badger Sharescott


People also ask

What does mysql_native_password mean?

The mysql_native_password authentication plugin is the default authentication plugin that will be used for an account created when no authentication plugin is explicitly mentioned and old_passwords=0 is set.

Is mysql_native_password secure?

Basically, mysql_native_password is the traditional method to authenticate- it is not very secure (it uses just a hash of the password), but it is compatible with older drivers.

How do I create a MySQL native password?

CREATE USER 'nativeuser'@'localhost'IDENTIFIED WITH mysql_native_password BY 'password'; Next, if you run MySQL locally you can modify your my. cnf file by adding the line shown below and restarting your MySQL service. This will validate all database users (including root) using mysql_native_password authentication.


2 Answers

Its problem of 'Remote Database Access Hosts'. "You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site."

MySql access is not granted to IP address of the system at which application is running.(in your case its '2.2.2.2' ).

Note:- '2.2.2.2' is your public IP address.

like image 176
yadavr Avatar answered Sep 17 '22 01:09

yadavr


Two possible things:

  1. MySQL is case sensitive make sure that the case of Database= in your connection string matches with the actual database name
  2. You may have to grant privileges to the user.

I hope this help you.

like image 34
Leonel Maye Avatar answered Sep 18 '22 01:09

Leonel Maye