Is it possible to use SSL with MySQL with the Database Toolbox 3.5 in MATLAB R2008b?
22 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 May 2010
Edited: MathWorks Support Team
on 22 Jul 2024
I would like to connect to a MySQL database using SSL to encrypt the connection. I am using JDBC and the "com.mysql.jdbc.Driver" driver. How can I achieve this?
Accepted Answer
MathWorks Support Team
on 17 Jul 2024
Edited: MathWorks Support Team
on 22 Jul 2024
In order to make use of SSL encryption to connect to your database, you will need the following:
1. The assistance of your database administrator to configure the MySQL server to accept SSL connections.
2. The SSL PEM public-key file that corresponds to your server's encryption key.
Here is the procedure:
1. Follow the steps in the MySQL documentation below to verify
(a) Your MySQL server has SSL support,
(b) You can use the MySQL Command-Line Client to connect to the server using SSL:
In particular, the following SQL command may be informative:
show variables like 'have_ssl'
If the answer from your server is "NO", then the server has no SSL support compiled into it. If the answer is "DISABLED", your system administrator does not start the MySQL server with SSL enabled. If the answer is "YES", you may be able to use SSL.
2. Follow the steps in the MySQL documentation below to configure your Java environment to use the server's PEM certificate with JDBC.
You can specify Java options for MATLAB by modifying or creating the "java.opts" file located here:
$MATLABROOT\bin\ARCH\java.opts
Here, $MATLABROOT is the directory where MATLAB is installed, and $ARCH is your computer's architecture, for example "win32".
3. Restart MATLAB
4. Modify your call to the DATABASE command from
hconn = database('DatabaseName','UserName','Passwd',...
'com.mysql.jdbc.Driver',...
'jdbc:mysql://HOST:PORT/DatabaseName')
to
hconn = database(''DatabaseName','Username','Passwd',...
'com.mysql.jdbc.Driver',...
'jdbc:mysql://HOST:PORT/DatabaseName?verifyServerCertificate=false&useSSL=true&requireSSL=true&')
Please note that the trailing "&" in the URL is required.
0 Comments
More Answers (0)
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!