用脚本加密MySQL流量 [英] Encrypting MySQL Traffic In Scripts

查看:85
本文介绍了用脚本加密MySQL流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够加密从Web服务器到数据库服务器的MySQL通信.我知道如何基于my.cnf中的服务器和客户端设置将MySQL设置为使用SSL,但这需要使用PHP中的mysql_connect()完成.这可能是一个两部分的问题.

I need to be able to encrypt the MySQL traffic from a web server to a database server. I know how to set MySQL to use SSL based on the server and client settings in my.cnf however, this needs to be done using mysql_connect() in PHP. This may be a 2 part question.

1)mysql_connect()是否使用my.cnf中设置的MySQL客户端设置?

1) Does mysql_connect() use the MySQL client settings that are set in my.cnf?

如果没有...

我已阅读到可以使用MYSQL_CLIENT_SSL,但是SSL数据是从哪里获得的?在mysql_connect函数中使用MYSQL_CLIENT_SSL是否可以自动加密流量?

I have read that you can use MYSQL_CLIENT_SSL however, where is the SSL data obtained from? Does using MYSQL_CLIENT_SSL in the mysql_connect function automagically encrypt the traffic?

简单地说,最好的方法是什么?

Simply put, what is the best way to do this?

谢谢!

推荐答案

如果使用SSL连接到MySQL,则SSL客户端和服务器之间的所有流量都将被加密.

If you connect to MySQL using SSL, all your traffic between your SSL client and server will be encrypted.

MYSQL_CLIENT_SSL已过时.如果需要使用SSL,请使用mysqli

MYSQL_CLIENT_SSL is obsolete. Using mysqli if you need to use SSL,

$db = mysqli_init(); 
$db->ssl_set(null, null,'cacert.pem',NULL,NULL); 
$db->real_connect('host','user','pass','db'); 

这篇关于用脚本加密MySQL流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆