Is it possible to use SSL with MySQL with the Database Toolbox 3.5 in MATLAB R2008b?
22 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2010-5-25
编辑: MathWorks Support Team
2024-7-22
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?
采纳的回答
MathWorks Support Team
2024-7-17
编辑:MathWorks Support Team
2024-7-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!