Unable to connect to any of the specified MySQL hosts.错误!
(1)c#连接Mysql数据建立连接时提示:Unable to connect to any of the specified MySQL hosts.(2)原因:数据库的服务器IP地址填写有错误(3)案例:例如:这种连接才是正确的public static string connectionString = "Database=test;Data Source...
文章共242字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
(1)c#连接Mysql数据建立连接时提示:Unable to connect to any of the specified MySQL hosts.
(2)原因:数据库的服务器IP地址填写有错误
(3)案例:
例如:
这种连接才是正确的
public static string connectionString = "Database=test;Data Source=test;Port=3306;UserId=root;Password=root;Charset=utf8;TreatTinyAsBoolean=false;Allow User Variables=True";
而自己却这样连接
public static string connectionString = "Database=test;Data Source=tests;Port=3306;UserId=root;Password=root;Charset=utf8;TreatTinyAsBoolean=false;Allow User Variables=True";
第二个很明显,IP地址就会有错误,就会出现Unable to connect to any of the specified MySQL hosts.错误了
(4)解决方法,就是对应服务器的连接方式,例如改为
public static string connectionString = "Database=test;Data Source=test;Port=3306;UserId=root;Password=root;Charset=utf8;TreatTinyAsBoolean=false;Allow User Variables=True";
的连接方式就可以解决Unable to connect to any of the specified MySQL hosts.错误了。
更多推荐
已为社区贡献1条内容
所有评论(0)