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

kanav_kapoor's avatar

php artisan migrate : PDOException could not find driver

I was in need to install Php 5.6 with postgres. I followed the instructions from here and did:

brew install php56 --without-mysql --without-apache --with-postgresql
brew install php56-pdo-pgsql

Php 5.6 and postgres are running fine with my Projects using PostgreSQL.

Now there is some problem with Laravel projects using mysql. On running php artisan migrate command, it shows:

[PDOException]
could not find driver

Project works fine in the browser though. Data is being fetched perfectly from the mysql tables. php -m also does not shows mysql. But phpinfo does shows mysql module.

What could be the problem? Do i need to reinstall mysql?

0 likes
13 replies
SaeedPrez's avatar

Sometimes there are two different PHP versions installed on a machine, one for CLI and one for the web server.

Check your phpinfo what php.ini is being used and also run php --ini in your CLI and check if it's the same.

1 like
kanav_kapoor's avatar

@ SaeedPrez

Yes, the phpinfo and php --ini show two different php.ini files.

But php version on php -v (on command prompt) is same as reflected on phpinfo()( on http server). Both show the updated version 5.6.

SaeedPrez's avatar

@kanav_kapoor

That tells us you either have two installations of php 5.6 or are using same installation but two different configuration files.

kanav_kapoor's avatar

@SaeedPrez

That's the problem bro. Which module to enable?

I am unable to find any pdo_mysql module that i can download or enable for OS X EL Captain.

SaeedPrez's avatar

See if you have the following line, uncomment it..

// Find this
;extension=php_pdo_mysql.dll

// Change to this
extension=php_pdo_mysql.dll
1 like
kanav_kapoor's avatar

I tried that already. Gives error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php56/5.6.23/lib/php/extensions/no-debug-non-zts-20131226/php_pdo_mysql.dll' - dlopen(/usr/local/Cellar/php56/5.6.23/lib/php/extensions/no-debug-non-zts-20131226/php_pdo_mysql.dll, 9): image not found in Unknown on line 0
SaeedPrez's avatar

@kanav_kapoor I'm not a mac/linux pro, but I believe you can run php -i | grep .ini to see if you have pdo_mysql installed.

kanav_kapoor's avatar

My problem is solved by:

brew unlink php56
brew install php56 --with-mysql

Can't believe it was that simple. I wasted about 4-5 hours on this stupid error. Thanks @SaeedPrez

1 like
kabircse's avatar

For Ubuntu 16.04 and PHP7 use sudo apt-get install php-mysql.

It solved my problem.

2 likes
zakir1929's avatar

I also have that issue but I executed migrate and seed command through route like that and it's solved my problem.

Route::get('/test', function(){
    Artisan::call('migrate');
    Artisan::call('db:seed');
});

Please or to participate in this conversation.