Fatal Error: Class ‘PDO’ Not Found Updated on May 12, 2022 by Scott Mitchell 3 Minutes, 28 Seconds to Read When working with Content Management Systems such as Drupal or other programs in your hosting account, you may run across certain errors during either the initial setup or even after a php or Apache upgrade on your server. One common error you may run across when trying to enter your site is the PDO error. It looks like the one below. Fatal error: Class ‘PDO’ not found in /home//public_html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php on line 72. This particular one occurred after an easyapache upgrade of Apache and PHP. Below are the things you should check in order to correct the issue. Check the PHP Modules List to See if It Is EnabledEnsure They Are Being Called in the php.ini FileEnsure the php.ini File Is RecursiveCheck the Extension Directory for PHPComment Out the extension_dir in php.ini Check the PHP Modules List to See if It Is Enabled The first thing we should check is to see if the server has the PDO extensions enabled. Log into your server via SSH.Run the command below. php -mYou will then be presented with a list of modules currently installed in php, listed alphabetically. Look for PDO in the list. If it exists, then the module is installed. mysqlnd openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Ensure They Are Being Called in the php.ini File If the PDO is displayed in the list of currently installed php modules, you will want to check the php.ini file in the relevant folder to ensure they are being called. Somewhere in the php.ini file you should see the following: extension=pdo.soextension=pdo_sqlite.soextension=pdo_mysql.soextension=sqlite.so If they are not present, simply add the lines above to the bottom of the php.ini file and save it. Ensure the php.ini File Is Recursive You will next want to ensure that the php.ini file is being used by all the folders and files underneath the main folder. This is known as being recursive. Below is a link to our article on doing just that. How can I make my php.ini file recursive ? Check the Extension Directory for PHP It is also possible that the php.ini file is looking into an incorrect extension directory, especially if you just performed an update. Below are the instructions for adjusting the extensions directory in the php.ini file: Log into your account via SSH.Navigate to the /usr/local/lib/php/extensions directory.Run the following command on the directory: ls -lah You will then see all the extension directories inside.root@vps#### [/usr/local/lib/php/extensions]# ls -lah drwxr-xr-x 5 root root 4.0K May 10 11:13 ./ drwxr-xr-x 15 root root 4.0K Aug 28 2021 ../ drwxr-xr-x 2 root root 4.0K Sep 2 2010 no-debug-non-zts-20060613/ drwxr-xr-x 2 root root 4.0K May 10 11:48 no-debug-non-zts-20090626/ drwxr-xr-x 2 root root 4.0K Oct 10 10:56 no-debug-non-zts-20100525/ Check the dates to find the most recent one. Notate the full name of that directory. In our example it is no-debug-non-zts-20100525. Now you will need to open your php.ini file. Navigate to the home directory and open the file using nano. cd /home/public_htmlnano php.iniOnce the file is opened, find the extension_dir setting and ensure that the path is the same as the latest one in your /usr/local/lib/php/extensions directory.; Directory in which the loadable extensions (modules) reside. extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525" Comment Out the extension_dir in php.ini One additional option to the above fix is to simply comment the line for the extension_dir setting out in the php.ini. Doing this does no harm as it simply makes the php use the extension directory from the main server php.ini, which is most probably the one you want. To do so, simply place a semicolon (;) at the very beginning of the line as demonstrated below. ; Directory in which the loadable extensions (modules) reside. extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525" Once you correct one or more of the above steps, you shoud no longer have any issues with the PDO error. Share this Article Related Articles How to Fix the “550 No Such User Here” Email Error Email Error – Mailbox Quota Exceeded Resolving DNS_PROBE_FINISHED_NXDOMAIN Errors How to Fix the Allowed Memory Size Exhausted Error How to Set a Custom 404 Page Using .htaccess MySQL 1064 Error: You have an error in your SQL syntax Chrome error: ERR_TOO_MANY_REDIRECTS Create a 503 Status Code for your Site I get a 404 error when I access cPanel Why is my Website Down? Post navigation WordPress Instagram Plugins – Instagram Picture What to do if you didn’t get the confirmation email from Melbourne IT for a domain transfer 13 thoughts on “Fatal Error: Class ‘PDO’ Not Found” Are you on a VPS/ Dedicated server? Hii have error in pdo connection in laravel 5.6 with php v 7.1 and also follow all steps but the error also appear Hello, Sorry for the problems with Laravel and PHP 7.1. We would need to know what specific error you’re seeing. Please provide more information about the error and the steps you’re taking so that we can attempt to duplicate the error if necessary. You may also want to look at other forums that have discussed a similar issue. Check out this post regarding an issue with Laravel 5.6 on a MAMP server and using PHP 7.1. Best!!! We are glad you enjoyed this article! Thanks for your feedback. Fatal error: Uncaught Error: Class ‘PDO’ not found in /var/www/localhost/appliance/cacti/lib/database.php:52 Stack trace: #0 /var/www/localhost/appliance/cacti/include/global.php(215): db_connect_real(‘localhost’, ‘cacti’, ‘secreto’, ‘cacti’, ‘mysql’, ‘3306’, false) #1 /var/www/localhost/appliance/cacti/include/auth.php(27): include(‘/var/www/localh…’) #2 /var/www/localhost/appliance/cacti/index.php(25): include(‘/var/www/localh…’) #3 {main} thrown in /var/www/localhost/appliance/cacti/lib/database.php on line 52 Did you follow the article above? It tells you how to solve this issue. If the article is not providing the help you need, then you will need to speak with support a developer who can review your website. If you have any further questions or comments, please let us know. Regards, Arnel C. Perfect solutions for PDO error i learned something and its help me a lot . THANK YOU ! Thank you! Commenting out the line worked perfectly (on an existing site after we upgraded the server to PHP 5.4). That was awesome.. You really helped me a lot 🙂 thanks alot .. very usefull… I just moved over to VPS1000 hosting from shared hosting. I called tech support, and they moved my php.ini file to the public_html directory. Then I added the extension lines as noted above, but it still didn’t work. However, once I commented out the extension_dir line as noted in the last step, it worked!!!! Thanks for the help! –Rob P. That was really great and informative. Comments are closed.
Hii have error in pdo connection in laravel 5.6 with php v 7.1 and also follow all steps but the error also appear
Hello, Sorry for the problems with Laravel and PHP 7.1. We would need to know what specific error you’re seeing. Please provide more information about the error and the steps you’re taking so that we can attempt to duplicate the error if necessary. You may also want to look at other forums that have discussed a similar issue. Check out this post regarding an issue with Laravel 5.6 on a MAMP server and using PHP 7.1.
Fatal error: Uncaught Error: Class ‘PDO’ not found in /var/www/localhost/appliance/cacti/lib/database.php:52 Stack trace: #0 /var/www/localhost/appliance/cacti/include/global.php(215): db_connect_real(‘localhost’, ‘cacti’, ‘secreto’, ‘cacti’, ‘mysql’, ‘3306’, false) #1 /var/www/localhost/appliance/cacti/include/auth.php(27): include(‘/var/www/localh…’) #2 /var/www/localhost/appliance/cacti/index.php(25): include(‘/var/www/localh…’) #3 {main} thrown in /var/www/localhost/appliance/cacti/lib/database.php on line 52
Did you follow the article above? It tells you how to solve this issue. If the article is not providing the help you need, then you will need to speak with support a developer who can review your website. If you have any further questions or comments, please let us know. Regards, Arnel C.
Thank you! Commenting out the line worked perfectly (on an existing site after we upgraded the server to PHP 5.4).
I just moved over to VPS1000 hosting from shared hosting. I called tech support, and they moved my php.ini file to the public_html directory. Then I added the extension lines as noted above, but it still didn’t work. However, once I commented out the extension_dir line as noted in the last step, it worked!!!! Thanks for the help! –Rob P.