简体   繁体   English

用hhvm找不到驱动程序MySQL

[英]Could not find driver MySQL with hhvm

I am using Laravel with HHVM. 我正在将Laravel与HHVM一起使用。

MySQL is working in normal controller functions. MySQL正在正常的控制器功能中工作。

But whenever from Commands (artisan), DB connection of MySQL (PDO) is initialised, then error comes of "could not find driver". 但是只要从Commands(技术人员)初始化MySQL的数据库连接(PDO),就会出现“找不到驱动程序”的错误。

Also I have tried writing connection initialisation from Controller function and calling it from Command still same error comes. 我也尝试从Controller函数编写连接初始化,并从Command调用它,仍然出现同样的错误。

$conn = new \PDO("mysql:host=$servername;dbname=$db_name", $username, $password);

I think you have not installed php-mysql driver 我认为您尚未安装php-mysql驱动程序

Try installing by using following command 尝试使用以下命令进行安装

sudo apt-get install php5 php5-mysql

Make sure the PDO mysql driver is enabled. 确保已启用PDO mysql驱动程序。

If you're running debian/ubuntu, you can check like this 如果您正在运行debian / ubuntu,则可以像这样检查

$ php -i | grep pdo
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini, # <-- This line
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

And if it's not enabled, you can enable it with: 如果未启用,则可以通过以下方式启用它:

$ php5enmod pdo_mysql

For other operating systems, you'll have to check the documentation. 对于其他操作系统,您必须检查文档。

Don't forget to restart your web server (Apache, or other). 不要忘记重启您的Web服务器(Apache或其他)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM