Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gregstewart90's avatar

could not find driver exception after upgrading Ubuntu to 17

I have a VPS hosting my laravel project. I upgraded the sever from Ubuntu 16 to 17 and had to completely uninstall mysql and all mysql clients to get mysql working from the command line. My laravel project is located in the /var/www/html/my-project-name directory. When I try to navigate to it from the web, I get a (PDOException could not find driver) exception. If I run php artisan server and view the project, I am able to connect and use the site normally.

I added phpinfo() to my project and I found the Loaded Configuration File is /etc/php/7.0/cli/php.ini. As other suggested, I added extension=mysql.so to that file. Still doesn't work even after restarting apache.

php -v PHP 7.0.18-0ubuntu0.17.04.1 (cli) (built: Apr 26 2017 23:59:48) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.18-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies

mysql --version mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper

0 likes
4 replies
mushketer888's avatar

If you run phpinfo() on web version of your project there mustn't be cli configuration. There must be folder /etc/php/7.0/apache/conf.d there is a list of loaded php modules . You can try to copy from /etc/php/7.0/mods-available/mysqli.ini to /etc/php/7.0/apache2/conf.d/ .But better to use symlinks. Also check php(your version)-mysl package installed. Or ls /etc/php/7.0/mods-available/ there must be mysqli.ini or similar.

gregstewart90's avatar

I did find a directory in /etc/php/7.0/apache2/conf.d. It contains many files. I created a symlink using sudo ln -s /etc/php/7.0/mods-available/mysqli.ini /etc/php/7.0/apache2/conf.d/mysqli.ini

The contents of /etc/php/7.0/mods-available/mysqli.ini follow: ; configuration for php mysql module ; priority=20 extension=mysqli.so

Still not working...

gregstewart90's avatar

When I add to my project, it is only visible when I use php artisan serve. The following is the output:

Server API Built-in HTTP server Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php/7.0/cli Loaded Configuration File /etc/php/7.0/cli/php.ini Scan this dir for additional .ini files /etc/php/7.0/cli/conf.d Additional .ini files parsed /etc/php/7.0/cli/conf.d/10-mysqlnd.ini, /etc/php/7.0/cli/conf.d/10-opcache.ini, /etc/php/7.0/cli/conf.d/10-pdo.ini, /etc/php/7.0/cli/conf.d/20-calendar.ini, /etc/php/7.0/cli/conf.d/20-ctype.ini, /etc/php/7.0/cli/conf.d/20-exif.ini, /etc/php/7.0/cli/conf.d/20-fileinfo.ini, /etc/php/7.0/cli/conf.d/20-ftp.ini, /etc/php/7.0/cli/conf.d/20-gd.ini, /etc/php/7.0/cli/conf.d/20-gettext.ini, /etc/php/7.0/cli/conf.d/20-iconv.ini, /etc/php/7.0/cli/conf.d/20-json.ini, /etc/php/7.0/cli/conf.d/20-mysqli.ini, /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini, /etc/php/7.0/cli/conf.d/20-phar.ini, /etc/php/7.0/cli/conf.d/20-posix.ini, /etc/php/7.0/cli/conf.d/20-readline.ini, /etc/php/7.0/cli/conf.d/20-shmop.ini, /etc/php/7.0/cli/conf.d/20-sockets.ini, /etc/php/7.0/cli/conf.d/20-sysvmsg.ini, /etc/php/7.0/cli/conf.d/20-sysvsem.ini, /etc/php/7.0/cli/conf.d/20-sysvshm.ini, /etc/php/7.0/cli/conf.d/20-tokenizer.ini

Please or to participate in this conversation.