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>
本文介绍了在使用C#连接MySQL数据库时遇到“Unable to connect to any of the specified MySQL hosts”错误的原因及解决方法。主要原因是由于配置文件中Server参数设置不当导致,详细解释了如何正确配置app.config文件中的Server参数。
5020

被折叠的 条评论
为什么被折叠?



