I am trying to connect my MySQL
database with C#
but it's not getting connected.
I am using
static string connstring = @"server=my.live.ip;userid=user;password=123;database=db_name;port=3306";
but still I am getting
Authentication to host 'my.live.ip' for user 'user' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'202.xxx.xxx.xxx' (using password: NO)`
I have searched on it but didn't find any suitable solution(s).
P.S: The live IP
that I am using is of azure
. i.e. MySQL
database is hosted on azure server via xampp
Any help would be highly appreciated
MySQL databases may be used by programs written in the C programming language on Socrates and Plato and on the IS Solaris workstations. Full details of the C API (Application Program Interface) are given in the MySQL manual.
To connect to the database server, confirm that the MySQL Database Server is running on your machine, right-click the Databases > MySQL Server node in the Services window and choose Connect. You might be prompted to supply a password to connect to the server.
Before you start to connect your application to MySql, you need to add add the mysql Reference in your project. To do so, right click our project name, and choose Add Reference, then choose "MySql. Data" from the list. Next, you need to add MySql Library in your C# project.
MySql. Data is an implementation of the ADO.NET specification for the MySQL database. It is a driver written in C# language and is available for all . NET languages.
(using password: NO)
says that no password was provided. I am not familiar with the connection syntax for C#, but I would suspect that something is wrong with
static string connstring =
@"server=my.live.ip;userid=user;password=123;database=db_name;port=3306";
Or perhaps connstring
is not being used.
Also check the MySQL side. Do SHOW GRANTS FOR 'user'@'202%'
or maybe SHOW GRANTS FOR 'user'@'202.xxx.xxx.xxx'
, depending on whether you used '202%'
or '202.xxx.xxx.xxx'
as the "host".
You should get back something like
GRANT ... ON dbname.* TO 'user'@'202%' WITH AUTHENTICATION 'mysql_native_password';
Note: having a hostname versus an IP address may be an issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With