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

tcetin's avatar

php artisan migrate "[PDOException] could not find driver" problem

Hi,

When I write command "php artisan migrate" from mysql connection,linux terminal gives this error :[PDOException] could not find driver.

When I add to php ini extension=pdo.so and extension=pdo_mysql.so , error has changing like this:

"PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/pdo_mysql.so' - /usr/lib/php5/20121212/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: Module 'PDO' already loaded in Unknown on line 0

[PDOException]
could not find driver " How can we solve this issue?

Thanks

0 likes
3 replies
Mbezdek's avatar
Mbezdek
Best Answer
Level 2

Hi, Do you have really installed mysql? In linux terminal: sudo apt-get install php5-mysql You need to have a module called pdo_mysql, as you write. Looking for following in phpinfo() -> pdo_mysql.

If it's OK, be sure to configure the DEFAULT key in app/config/database.php and in .env file.

2 likes
tcetin's avatar

sudo apt-get install php5-mysql, solved my problem

ontzuevanhussen's avatar

Laravel 4: Change "host" in the app/config/database.php file from "localhost" to "127.0.0.1"

Laravel 5: Change "DB_HOST" in the .env file from "localhost" to "127.0.0.1"

Laravel w/ Homestead: Use the directions above for the Laravel version you are using BUT change "localhost" to the IP address specified in Homestead.yaml. The default is "192.168.10.10" instead of "127.0.0.1"

1 like

Please or to participate in this conversation.