当我使用Docker将ABP发布到Ubuntu时,无法连接到任何指定的MySQL主机

时间:2018-03-14 04:42:04

标签: c# asp.net asp.net-core asp.net-core-2.0 asp.net-boilerplate

我尝试使用Docker向Ubuntu发布My Asp Boilerplate项目,但是我遇到了问题。无法连接到任何指定的MySQL主机。

--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
**crit:** Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
      Application startup exception
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
   at MySqlConnector.Core.ServerSession.<ConnectAsync>d__56.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\ServerSession.cs:line 239
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlConnection.<CreateSessionAsync>d__77.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnection.cs:line 365

这是我的 连接,

 {
      "ConnectionStrings": {
        "Default": "Server=128.199.250.219; Database=CityInfoDb; User Id=****; Password=******;"
      },
      "App": {
        "WebSiteRootAddress": "http://localhost:9903/"
      }
    }

我的Docker文件, dockerfile

Mysql, mysql

也许我的dockerfile不正确,请帮帮我,我很沮丧。

1 个答案:

答案 0 :(得分:0)

您的连接字符串似乎不正确,请在示例下方找到。

{

"ConnectionStrings": {
"Default": "server=127.0.0.1;uid=root;pwd=1234;database=mysqldemodb"
},
 ...
}

您可以参考EF Core MySql Integration