C# - 意外的身份验证方法 mysql_native_password 异常

C# - Unexpected authentication method mysql_native_password exception(C# - 意外的身份验证方法 mysql_native_password 异常)

本文介绍了C# - 意外的身份验证方法 mysql_native_password 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此一无所知,但我一直在尝试使用 SQL 数据库进行一些练习.我尝试了 MSSQL 并感到沮丧,所以我尝试了 MySQL 并走得更远.数据库似乎已经启动并正在运行,我什至做了一个查询来创建一个表.虽然在尝试连接 Microsoft 的 C# Express 版本时出现异常:意外的身份验证方法 mysql_native_password"我知道密码是正确的.我什至在引用 MySQL.Data.dll.这是我的代码,我在 connection.Open() 上遇到异常.有人可以帮帮我吗?

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();
            }
        }
     }

推荐答案

您使用的是什么提供商?如果您使用的是 MySQL Connecter .net,那么您的连接字符串应该类似于...

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;

如果您使用的是 eInfoDesigns 提供程序,那么...

If you are using eInfoDesigns provider, then...

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

如果有七个对象

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

如果德瓦特

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;

如果是 MySQLDriverCS

if MySQLDriverCS

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

如果 MySql OLEDB

if MySql OLEDB

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

如果.Net OLEDB

if .Net OLEDB

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

如果 MySQl 连接器

if MySQl Connector

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

更多帮助可以在这里找到http://www.connectionstrings.com/mysql

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

实际上使用 SQL Server 要容易得多,因为它是内置的,而 VS 旨在与它一起工作.

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

这篇关于C# - 意外的身份验证方法 mysql_native_password 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:C# - 意外的身份验证方法 mysql_native_password 异常

基础教程推荐