MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.

在本地的电脑上测试用的MySql用的一般默认的端口3306,在远程服务器上安装时修改成了3307端口,本地连接和远程连接都可以访问,在C#使用连接字符连接数据库时报错了

System.AggregateException: 发生一个或多个错误。 ---> System.Data.Entity.Core.ProviderIncompatibleException: 提供程序未返回 ProviderManifestToken 字符串。 ---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.

<add name="SpanEpochDADbContext" connectionString="server=192.168.228.128;user id=root;password=admin;persistsecurityinfo=True;Character Set=utf8;database=TTPT_SpanEpochDA2" providerName="MySql.Data.MySqlClient"/>

后面才发现连接字符串上没有写端口,如果使用3306端口是不需要写端口的,修改了默认的端口要在连接字符串后面加上;PORT=3307就可以

posted @ 2019-12-23 19:38  Li_Jw  阅读(2287)  评论(0编辑  收藏  举报