Linux 如何为php启用mysqlnd?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13159518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to enable mysqlnd for php?
提问by SimonW
I have PHP installed and running (version: 5.3.17) and I want to switch to mysqlnd (in the phpinfo mysqlnd does not exist at all).
我已经安装并运行了 PHP(版本:5.3.17),我想切换到 mysqlnd(在 phpinfo 中 mysqlnd 根本不存在)。
I read that in order to set it, you need to update the ./configure
command:
我读到为了设置它,您需要更新./configure
命令:
./configure --with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
When I tried installing it with yum install php-mysqlnd
I get an error:
当我尝试安装它时yum install php-mysqlnd
出现错误:
---> Package php-mysqlnd.x86_64 0:5.3.17-1.26.amzn1 will be installed
--> Processing Conflict: php-mysql-5.3.17-1.26.amzn1.x86_64 conflicts php-mysqlnd
--> Finished Dependency Resolution
Error: php-mysql conflicts with php-mysqlnd
采纳答案by Sebastian Ke?ler
The ./configure
command is part of the compilation process from source code.
该./configure
命令是源代码编译过程的一部分。
You can either compile from source or install via package manager. I guess in your case the package manager is preferable.
您可以从源代码编译或通过包管理器安装。我想在你的情况下,包管理器更可取。
As the package manager complains, you can't have both php-mysql
and php-mysqlnd
installed.
正如包管理器所抱怨的,您不能同时安装php-mysql
和php-mysqlnd
安装。
So you can
这样你就可以
yum remove php-mysql
before
前
yum install php-mysqlnd
Then check for success via
然后通过检查是否成功
php -m | grep mysqlnd
or
或者
php -i | grep mysqlnd
回答by donald123
Don't know if i understand you right.... Simply download the source of php (php-5.x.x.tar.gz), unzip the source and change to that directory then
不知道我理解对不对....只需下载php的源代码(php-5.xxtar.gz),解压源代码并切换到该目录然后
bash:/dir/of/your/source # ./configure --with-mysql=... and your other config params
after that just make it by
之后就可以了
bash:/dir/of/your/source # sudo make && make install
回答by 000
As of PHP 5.4, the mysqlnd library is a php.net compile time default to all PHP MySQL extensions. - Ref: dev.mysql.com
从 PHP 5.4 开始,mysqlnd 库是所有 PHP MySQL 扩展的 php.net 编译时默认库。- 参考:dev.mysql.com
it would be a little easier to use XAMPP for Linux 1.8.1(it comes with PHP 5.4.7) then compiling from source.
使用XAMPP for Linux 1.8.1(它随 PHP 5.4.7 一起提供)然后从源代码编译会更容易一些。
回答by John61590
yum install php-mysqlnd
is only available on CentALT and maybe remi repos. Webtatic also has some good php repos as well. It is NOT on the default ones (I was using CentOS).
yum install php-mysqlnd
仅在 CentALT 和 remi repos 上可用。Webtatic 也有一些不错的 php 存储库。它不是默认的(我使用的是 CentOS)。
回答by iamarobot
yum swap php-mysql php-mysqlnd
回答by Ajowi
I may be late with this but it could be of help to others. As already said elsewhere in the forum, if a call to a function like get_result complains that it is undefined, then php-mysqlnd need to be installed (this question). I realized that doing yum install (centos) will automatically reports that it wants to remove php-mysql and phpmyadmin; do not accept this as your phpmyadmin may not work after. Instead, use yum shell which will take the commands at once and gracefully handle the change over; do these in command line:
我可能会迟到,但它可能对其他人有所帮助。正如论坛其他地方已经说过的,如果调用像 get_result 这样的函数抱怨它是未定义的,那么需要安装 php-mysqlnd(这个问题)。发现做yum install(centos)会自动报要删除php-mysql和phpmyadmin;不要接受这一点,因为您的 phpmyadmin 可能无法正常工作。相反,使用 yum shell 它将立即接收命令并优雅地处理更改;在命令行中执行这些操作:
# yum shell
> remove php-mysql
> install php-mysqlnd
> run
> quit
Now you may have to restart both the mariadb (most likely) and the httpd services.
现在您可能必须重新启动 mariadb(最有可能)和 httpd 服务。