Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 840
Sea Avatar asked Jul 13 '17 16:07

Sea


People also ask

How do I fix SSL connection error in MySQL?

right-click on the particular MySQL instance and select "Edit Connection" Select the "SSL" tab under Connection Method. Select the drop-down for the "Use SSL" and choose "If Available" instead of "Required". Click the "Test Connection" button at the lower right connection to make sure you can now connect without errors ...

How do I enable SSL on MySQL server?

Enable SSL Connections on MySQL Now, connect to the MySQL shell and check the status with the following command: mysql -u root -p --ssl-mode=required mysql> SHOW VARIABLES LIKE '%ssl%'; You should see that both have_openssl and have_ssl variables are now enabled.

How can I connect to MySQL database without SSL?

You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. If you want to avoid the above MySQL warning, use the syntax mention in the beginning.

Does MySQL client use SSL?

MySQL supports encrypted connections between clients and the server using the TLS (Transport Layer Security) protocol. TLS is sometimes referred to as SSL (Secure Sockets Layer) but MySQL does not actually use the SSL protocol for encrypted connections because its encryption is weak (see Section 6.3.


2 Answers

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)

like image 127
JDC Avatar answered Sep 25 '22 14:09

JDC


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); 
like image 36
Anuj Avatar answered Sep 26 '22 14:09

Anuj