使pdo_mysql驱动程序在CLI中工作 [英] Getting pdo_mysql driver to work in CLI

查看:77
本文介绍了使pdo_mysql驱动程序在CLI中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CLI中的pdo_mysql扩展名有问题.我正在使用本地LAMPP安装并制作了一个info.php文件,可以看到我启用了PDO和mysql驱动程序.但是,当我在命令行中写入php --ri mysql时,它会返回扩展名'mysql'不存在. 我已经读过php.ini,一个是CLI的,一个是为浏览器加载的,我看不出pdo配置没有区别. PDO已为CLI激活,但pdo_mysql未激活,我找不到任何pdo_mysql.so文件或任何其他文件或行,这些文件或行告诉我为什么它从浏览器而不是从cli运行.有帮助吗?

I have a problem with the pdo_mysql extension in CLI. I'm working with a local LAMPP installation and making a info.php file I can see that I have PDO and the mysql driver enabled. But when I write php --ri mysql in the command line it returns Extension 'mysql' not present. I've read both php.ini, the one for CLI and the one that loads for the browser and I can't see no differences in the pdo configuration. PDO is activated for CLI but pdo_mysql is not and I can't find any pdo_mysql.so file or any other file or line that tells me why is it working from the browser and not from the cli. Any help?

非常感谢您.

推荐答案

问题已解决.我有两个php安装程序,一个由LAMPP安装,具有所有必需的pdo驱动程序,一个安装在系统中(我不知道默认情况下ubuntu附带了它,还是我在某个时候安装了它),并且启用了PDO,但没有PDO司机. CLI可以与第二个PHP一起使用,除非您另行通知.我正在通过CLI使用Doctrine,但正在执行一个bash文件,该文件调用了一些php代码.在.doctrine文件的第一行中,我可以告诉系统我要使用什么php:

Problem solved. I have two php installations, one installed by LAMPP that has all the required pdo drivers and one installed in the system (I don't know if it comes with ubuntu by default or I installed it at some point) with PDO enabled but no PDO drivers. CLI works with the second PHP unless you tell him otherwise. I was working with Doctrine from the CLI but I was executing a bash file that calls some php code. In the first line of the .doctrine file I can tell the system what php I want to use:

#!/root/to/lampp/php

它起作用了(实际上,它没有创建应该创建的数据库表,但这是另一个问题,我仍然要解决.

And it worked (actually it doesn't create the database tables that it's supposed to create but that's a different problem thet I still have to solve.

这篇关于使pdo_mysql驱动程序在CLI中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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