C# - 意外的认证方法mysql_native_password异常 [英] C# - Unexpected authentication method mysql_native_password exception
问题描述
我没有看到这个东西,但我一直在试图时间最长得到一些做法与SQL数据库。我试过MSSQL和很沮丧没有尽头,所以我尝试MySQL和有一点更进一步。该数据库似乎是建立和运行,我甚至做了查询,以表。虽然他们试图与微软的C#Express版本连接时,我得到异常:意外的认证方法mysql_native_password我知道密码是正确的。我甚至引用MySQL.Data.dll。这里是我的代码,我得到connection.Open除外()。是否有人可以帮我吗?
公共Form1中()
{
的MySqlConnection连接=新的MySqlConnection(数据源=本地主机;初始目录= MySQL55;集成安全性= SSPI;用户ID =根;密码=<免去取代;);
试
{
connection.Open();
}
终于
{
如果
{
的Connection.close()(连接!= NULL);
}
}
}
什么提供商您使用的?
。如果你正在使用MySQL连接器.NET,那么你的连接字符串应该是这样...
服务器= myServerAddress;数据库= MyDatabase的; UID =名为myUsername; PWD = MYPASSWORD;
如果您使用的是eInfoDesigns提供商,然后...
数据源= myServerAddress;数据库= MyDatabase的;用户ID =名为myUsername;密码= MYPASSWORD;命令日志记录= FALSE;
如果SevenObjects
主机= myServerAddress;用户名=名为myUsername;密码= MYPASSWORD;数据库= MyDatabase的;
如果Devart
用户ID =根;密码= MYPASSWORD;主机=本地主机,端口= 3306;数据库= MyDatabase的;直接= TRUE;协议= TCP,压缩= FALSE;池= TRUE;闵池大小= 0;最大池大小= 100;连接生存期= 0;
如果MySQLDriverCS
位置= myServerAddress;数据源= MyDatabase的;用户ID =名为myUsername;密码= MYPASSWORD;端口= 3306;扩展属性=
如果MySQL OLEDB
提供程序= MySQLProv;数据源= mydb的;用户ID =名为myUsername;密码= MYPASSWORD;
如果净OLEDB
提供程序= MySQLProv;数据源= mydb的;用户ID =名为myUsername;密码= MYPASSWORD;
如果MySQL连接器
驱动器= {MySQL的ODBC 5.5驱动程序};服务器=本地主机;数据库= MyDatabase的;用户=名为myUsername;密码= MYPASSWORD;选项= 3;
更多帮助,可以在这里找到的 http://www.connectionstrings.com/mysql
它实际上是更容易使用SQL服务器,因为它是内置的,VS是设计它的工作。
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();
}
}
}
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.
这篇关于C# - 意外的认证方法mysql_native_password异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!