Reputation: 150
I am working on .NET Core project with MySQL on an Ubuntu Server. I am using Visual Studio on a Mac. The NuGet package I installed is MySql.Data 8.0.8-dmr, it's not a stable version (maybe that's just the point, but let me go on).
I have no SSL certificates on that machine, it's just in the local network for development purposes.
I am using a connection string that looks like this: Server=[Ip address to that server]; Port=3306; Database=MyDatabase; Uid=MyUser; Pwd=MyPassword; SslMode=Preferred;
When I connect with MySQL Workbench with SSL Mode configured to "if available", the connection works fine. When I try to do this connection with my code, an exception of the type System.ArgumentException is thrown:
Value 'Preferred' is not of the correct type.
If I change SslMode to "None" in the connection string, my code can connect to the MySQL server.
I do not understand, why it does not work with the "Preferred" value. Shouldn't it be the fallback option anyway, when I say "Preferred"?
The MySQL server has this version: 5.7.18-0ubuntu0.16.04.1.
Upvotes: 1
Views: 4857
Reputation: 1019
Check this link MySQL connection strings. You need to have the Connector/.Net package which I think you don't. Also you need at least version 6.2.1.
Also, here is the Deployment guide on how to deploy it on an Ubuntu Server.!
On another note from this link, the default value for SslMode is 'Preferred', so I would think there are no problems there.
Upvotes: 0