102

I use MySql.Data 8.08 and .NET Core to connect to MySql 5.7.18 but following exception is being thrown:

MySql.Data.MySqlClient.MySqlException:“The host localhost does not support SSL connections.”

How to deal with it?

Sea
  • 1,033
  • 2
  • 8
  • 5
  • 2
    I would assume you have two options: - [Enable SSL connectivity on your MySQL server](https://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-ssl.html) - [Connect to your MySQL server without enforcing an SSL connection](https://dev.mysql.com/doc/connector-net/en/connector-net-connection-options.html) – abolotnov Jul 13 '17 at 16:59

2 Answers2

229

I had the same problem today when moving from MySql.Data 7.0.7 to 8.0.8. I was able to move forward adding the "SslMode=none" in the connection string.

You will endup with something like:

server={0};user id={1};password={2};persistsecurityinfo=True;port={3};database={4};SslMode=none

(replacing the values with your database details)

JDC
  • 3,078
  • 1
  • 17
  • 15
  • thanks. It worked,must Added SSL for negative like SslMode=none – Sea Jul 15 '17 at 02:08
  • 6
    trying to force SSL connection is a good idea but breaking people code assuming they would have SSL available is not! If I had SSL I would use it already! – dvdmn Jul 31 '18 at 20:46
  • Thanks for this information. I too was facing runtime error on live server without an hint how to move-on, because everything worked properly on local/dev. I have consolidated all the issue I've faced during Mysql client 6.x to 8.x migration in this [article](https://davidsekar.com/asp-net/mysql-error-the-provider-did-not-return-a-providermanifesttoken). Hope this saves time. – David Chelliah Aug 08 '18 at 09:32
  • Disable SSL connection brake security roles. So in my opinion thoes solution fix that issue ONLY for dev purposes not for production – Jerzy Drożdż Jun 15 '21 at 17:44
  • Faced this error after migrating from .Net Core 3.1 to .Net 5.0 – Kattabomane Aug 10 '21 at 16:42
  • @Kattabomane similar for me with 3.1 to 6.0. Another note: I didn't have the issue when I run the code in debug (windows IIS Express), only when I ran it in production (linux). Very difficult to track down. – T3.0 Jan 04 '23 at 14:26
2

And if you using a connection pool class, then you might have to do this way:

    string connstring = string.Format("Server=44.55.110.59; database={0}; UID=root; password=Newuser@123; SslMode = none", databaseName);
Anuj
  • 149
  • 2
  • 11