dongzouban9871 2011-04-23 09:19
浏览 92

将PHP mysql库从mysqlnd更改为libmysql(用于SSL连接)

I am using the most recent PHP 5.3.6 on a Windows box. I configured a remote MySQL server to accept only SSL connections. Connecting works fine with the MySQL command line client:

mysql.exe -u user -h mysql.example.com -P 3307 --ssl-ca=C:\www\mysql.example.com.crt -p

However, I cannot connect through PHP. According to the PHP documentation, this is due to PHP 5.3 using the newer MySQL Native Driver (mysqlnd) by default. This driver does not support SSL.

I can't believe that they allowed such a regression to slip through (SSL being one of the few reasons why someone would use the mysqli rather than the mysql extension) without offering an easy way to revert back to the old libmysql driver which does support SSL.

On php.net, there is no indication about how to do this. Also, recompiling is not an option. My question thus is: how can this be done easily?

  • 写回答

1条回答 默认 最新

  • douqian9729 2011-04-23 19:47
    关注

    On php.net, there is no indication about how to do this. Also, recompiling is not an option.

    In order to create the mysql, mysqli and PDO extensions, PHP must be compiled against a MySQL interface library. You can't simply swap out that underlying library. In order to use another library, like the one provided by MySQL, you have to recompile PHP against it.

    The reason for the switch to the native library is that the MySQL-provided library is released under the GPL. The PHP license is not compatible with the GPL, so distributing PHP binaries compiled against GPL code is pretty high up on the Thou Shalt Not list. You can thank and/or curse the MySQL folks for this bit of utter stupidity. Only idiots and evil people release library code under the GPL.

    </rant>

    If you can't recompile, you're probably out of luck. Keep in mind that Microsoft offers VC9 (Visual Studio 2008) at no cost, so you should be able to perform the recompile, if needed.

    You might want to explore other options for a secure connection to your MySQL server.

    If the remote machine is Linux or otherwise Unix-based, then using an SSH tunnel (port forwarding) may work for you. There are numerous SSH clients for Windows that can do this.

    You should also consider OpenVPN, a VPN solution built on top of SSL/TLS. You can use this to establish a secure connection between the two machines without needing to worry about protocol-level security.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?