我使用 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粉3080890802023-09-16 10:25:58
只要將 define("DB_TYPE", "mysqli");
改為 define("DB_TYPE", "mysql");
因為我只得到了 mysql_pdo