【问题标题】:MySQL: Server does not exist or connection refusedMySQL:服务器不存在或连接被拒绝
【发布时间】:2017-10-14 04:21:56
【问题描述】:

我有一个在 localhost:3306 下运行的 MySQL 数据库。使用像 sequel pro 这样的程序,我可以毫无问题地连接到数据库。

如果我尝试在 asp .net core 和 Dapper 中使用连接字符串连接这些数据库:

<connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient"
         connectionString="Server=127.0.0.1;Database=test;User ID=admin;Password=secret;" />
</connectionStrings>

我收到以下错误消息:

System.Data.SqlClient.SqlException (0x80131904): Server does not exist or connection refused.

我不知道为什么。 有人可以帮帮我吗?

【问题讨论】:

标签: c# mysql asp.net


【解决方案1】:

我认为您的连接字符串是underspecified,因为它缺少端口号。 3306是specific to MySQL,所以要明确说明如下:

connectionString="Server=tcp:.,3306;Database=test..."

【讨论】:

  • 现在我得到这个错误:System.Exception: Unknown packet type 74
  • 好的,那么连接器不知道如何处理 MySQL。您可以尝试使用来自this answer 的 MySQL 特定连接器吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多