在 Apache2 PHP 7.4 上的 PDODb 上找不到驅動程式
P粉470645222
P粉470645222 2023-09-15 14:55:04
0
1
601

我使用 Ubuntu 22.04 和 php 7.4。我嘗試使用 apache2 為我的網站提供虛擬主機。可以開啟登入頁面,在我們插入帳號後,錯誤顯示 could not find driver on /var/www/website/app/models/PDODb.php on line229 that line is

$this->pdo = new PDO($connectionString, $this->connectionParams['username'], $this->connectionParams['password'], $options);

我已經取消註解了 php.ini 上的 extension=pdo_mysql 並且已經重新啟動了 apache2。 使用 php -i | grep pdo_mysql會導致這個

/etc/php/7.4/cli/conf.d/20-pdo_mysql.ini,
API Extensions => mysqli,pdo_mysql
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

這是我的 website.conf

##
<VirtualHost *:80>

        ServerName localhost

        ServerAlias localhost
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/website
        DirectoryIndex /index.php index.php /index.html index.html
        <Directory "/var/www/website">
        AllowOverride All
        Require all granted
    </Directory>
   RewriteEngine on     
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

這是我用來連接資料庫的 config.php 定義(“DB_HOST”,“127.0.0.1”);

define("DB_USERNAME", "root");
define("DB_PASSWORD", "root123");
define("DB_NAME", "db_website");
define("DB_TYPE", "mysqli");
define("DB_PORT", "");
define("DB_CHARSET", "utf8");

我已經嘗試遵循這個問題,但它仍然給我相同的結果。我該怎麼辦?

P粉470645222
P粉470645222

全部回覆(1)
P粉308089080

只要將 define("DB_TYPE", "mysqli"); 改為 define("DB_TYPE", "mysql"); 因為我只得到了 mysql_pdo

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!