1

I didn't see anything on this, but I've been trying for the longest time to get some practice with an SQL database. I tried MSSQL and was frustrated to no end, so I tried MySQL and got a bit further. The database seems to be up and running, and I even did a query to make a table. Although when trying to connect with Microsoft's C# Express edition I get the exception: "unexpected authentication method mysql_native_password" I know the password is correct. I'm even referencing MySQL.Data.dll. Here's my code, I get the exception on connection.Open().Can someone please help me out?

     public Form1()
     {
      MySqlConnection connection = new MySqlConnection("Data Source = localhost;          Initial Catalog = MySQL55; Integrated Security = SSPI; User ID = root; Password = <REMOVED>;");

        try
        {
            connection.Open();
        }

        finally
        {
            if (connection != null)
            {
                connection.Close();
            }
        }
     }

1 Answer 1

10

What provider are you using? If you are using MySQL Connecter .net, then you connection string should be something like...

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

If you are using eInfoDesigns provider, then...

Data Source=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Command Logging=false;

If SevenObjects

Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase;

if Devart

User ID=root;Password=myPassword;Host=localhost;Port=3306;Database=myDataBase; Direct=true;Protocol=TCP;Compress=false;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;

if MySQLDriverCS

Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;Password=myPassword;Port=3306;Extended Properties="""";

if MySql OLEDB

Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

if .Net OLEDB

Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

if MySQl Connector

Driver={MySQL ODBC 5.5 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;

More help can be found here http://www.connectionstrings.com/mysql

It is actually much easier to use SQL Server as it is built in and VS is designed to work with it.

Sign up to request clarification or add additional context in comments.

1 Comment

This sort of helped, but now I'm getting an unknown database error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.