Home > Database > Mysql Tutorial > body text

How to Fix the \'PHP Fatal error: Class \'PDO\' not found\' Exception?

DDD
Release: 2024-11-27 00:05:11
Original
936 people have browsed it

How to Fix the

Resolving "PHP Fatal error: Class 'PDO' not found" Exception

The "Class 'PDO' not found" error typically occurs when the PHP Data Objects (PDO) extension is not installed or enabled. To resolve this issue, follow these steps:

1. Check if PDO is installed:

Run the following command to check if PDO is installed:

php -m | grep PDO
Copy after login

If PDO is installed, it will be listed as an extension.

2. Enable PDO in PHP.ini:

If PDO is installed but not enabled, open the PHP.ini file and look for the following lines:

extension=pdo.so
extension=pdo_mysql.so
Copy after login

Ensure that these lines are uncommented (i.e., do not have a semicolon at the beginning of the line).

3. Install and enable PDO MySQL:

The specific error "Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php" indicates that the MySQL PDO driver is not enabled. Run the following commands to install and enable it:

sudo yum install php-pdo
sudo yum install php-pdo_mysql

service httpd restart
Copy after login

Once these steps are completed, restart your Apache web server (e.g., Apache, Nginx, etc.). The "Class 'PDO' not found" error should now be resolved.

The above is the detailed content of How to Fix the \'PHP Fatal error: Class \'PDO\' not found\' Exception?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template