Home >Backend Development >PHP Tutorial >Why Am I Getting a PDOException 'could not find driver' in PHP and How Do I Fix It?
PDOException "could not find driver" in PHP
A developer has encountered an error while attempting to establish a database connection using PHP's PDO. The specific error message indicates that the required MySQL driver could not be found.
Possible Cause:
The error is caused by the absence of the pdo_mysql module, which is necessary for PHP to communicate with MySQL databases.
Resolution:
To resolve the issue, you need to install the missing pdo_mysql module. Here's how:
pdo_mysql PDO Driver for MySQL, client library version => 5.1.44
sudo apt-get install php-mysql
sudo service apache2 restart
Once the pdo_mysql module is installed and the web server is restarted, the PDOException "could not find driver" error should be resolved.
The above is the detailed content of Why Am I Getting a PDOException 'could not find driver' in PHP and How Do I Fix It?. For more information, please follow other related articles on the PHP Chinese website!