由于缺少PHP扩展,CakePHP 3无法连接到数据库

r6vfmomb  于 2023-04-06  发布在  PHP
关注(0)|答案(6)|浏览(152)

我试图安装cakePHP 3.0.0与WT-NMP,但我得到了这样的消息:
CakePHP无法连接到数据库。
数据库驱动程序Cake\Database\Driver\Mysql由于缺少PHP扩展或未满足的依赖项而无法使用
我的php.ini有这个:

extension = php_bz2.dll
extension = php_curl.dll
extension = php_gd2.dll
extension = php_imap.dll
extension = php_mbstring.dll
extension = php_exif.dll
extension = php_mysql.dll
extension = php_mysqli.dll
extension = php_pdo_mysql.dll
extension = php_pdo.dll
extension = php_soap.dll
extension = php_sockets.dll
extension = php_sqlite3.dll
extension = php_openssl.dll
extension = php_fileinfo.dll
extension = php_intl.dll

app.php有这个

'default' => [
        'className' => 'Cake\Database\Connection',
        'driver' => 'Cake\Database\Driver\Mysql',
        'persistent' => false,
        'host' => 'localhost',
        /**
         * CakePHP will use the default DB port based on the driver selected
         * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
         * the following line and set the port accordingly
         */
        'port' => '3306',
        'username' => 'root',
        'password' => '',
        'database' => 'test',
        'encoding' => 'utf8',
        'timezone' => 'UTC',
        'cacheMetadata' => true,

我错过了什么?或者这是cakePHP 3.0的bug?或者任何与WT-NMP有关的东西。我已经被卡住了一整天。

pinkon5k

pinkon5k1#

幸运地解决了这个问题!:

extension = php_intl.dll
extension = php_pdo_mysql.dll
intl.default_locale = en_utf8
intl.error_level = E_WARNING
bogh5gae

bogh5gae2#

安装modules for MySQL database connections为我解决了这个问题:

#Install the package
sudo apt-get install php5-mysql
#Restart Apache
sudo service apache2 restart

来源:http://guru4cakephp.blogspot.nl/2015/04/install-cakephp-3-on-ubuntu.html
Package 详情:https://packages.debian.org/sid/php5-mysql

jobtbby3

jobtbby33#

试试这个:
PHP 7.0

sudo apt-get install php7.0-mysql

对于PHP 5:

sudo apt-get install php5-mysql
nhhxz33t

nhhxz33t4#

错误消息是因为extension = php_pdo_mysql.dll没有在php.ini中安装和启用。如果您没有启用php_intl.dll,则在检查数据库连接之前会收到错误消息。
您的php.ini表明您已经启用了php_pdo_mysql.dll,但是可能您需要重新启动CakePHP服务器bin/cake server

h43kikqp

h43kikqp5#

不要仅仅依赖于php.ini的阅读。只要检查你是否安装了php[v]-mysql扩展。你可以检查php_mysql.dll是否存在于你的windows服务器的php扩展目录(最有可能是<path to your php installation>/ext)中。在linux中,你可以使用以下命令检查它是否安装。

yum list installed | grep php

它将列出所有已安装的php扩展。

jrcvhitl

jrcvhitl6#

对于Windows:

extension=pdo_sqlite
extension=sqlite3

相关问题