Using TLS when connecting to MySQL server

If you like to connect to MySQL or MariaDB from Xojo with MBS Xojo SQL Plugin, you can set SSL options to connect through an encrypted connection. The options are named SSL, but nowadays it’s all TLS v1.2 or newer.

Here is a sample code snippet to connect to a MySQL server to download data, e.g. from a web shop:

Dim con As New SQLConnectionMBS

con.SetFileOption con.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")
con.SetFileOption "MYSQL_SSL_CA", SpecialFolder.UserHome.Child("cacert.pem")


dim server as string = ",3306@test"


If you have trouble or questions, please don’t hesitate to contact us. If you need a cacert.pem file, you can go to the CURL website. You need to pick the mysql library name based on the platform.
While you can download MySQL or MariaDB servers and client software, we provide a convenient library download on our website: Libraries. The MySQL 8 files there include SSL libraries, so use the MySQL client libraries when you want to connect via SSL.

1 Like