Unable to connect to any of the specified MySQL hosts.

xiaoxiao2021-02-28  60

c#连接Mysql数据建立连接时提示:Unable to connect to any of the specified MySQL hosts.

出现此错误的原因是Server(数据库服务器IP地址填写错误)

当Server配置值是“(local)”或者是"(localhost)"时都会产生此错误,连接MSSQL时使用“(local)”是可以的,但连接MySQL是不行的,正确的方法是不使用小括号,例如下面的 app.config 文件中的配置:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="Default" connectionString="server=localhost;uid=root;pwd=root;database=DreacomSpider" providerName="mysql" /> </connectionStrings> </configuration>

转载请注明原文地址: https://www.6miu.com/read-55070.html

最新回复(0)