2

I am using:

  • php 7.2
  • laravel 5.8
  • ubuntu 19

php artisan migrate throwing this error:

**Illuminate\Database\QueryException  : could not find driver (SQL: select * from information_schema.tables where table_schema = laraveldb and table_name = migrations and table_type = 'BASE TABLE')**

1. PDOException::("could not find driver")
  /home/amar/sandbox/l5/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2. PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "localhost", [])
  /home/amar/sandbox/l5/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Amar
  • 21
  • 5

2 Answers2

1

Add extension=pdo_mysql.so in your php.ini file and ensure that you have restart the server after you make the changes to the php.ini file otherwise changes may not be reflected. You can check many approaches in this link also - click-here

Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
  • Thanks. After adding extension=pdo_mysql.so and restarting my server. I again run migrate command and it gives following warning: "PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_mysql.so.so (/usr/lib/php/20170718/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0" – Amar Sep 19 '19 at 19:59
  • Try `sudo apt-get update` and `sudo apt-get install php7.2-pdo` – Rashed Hasan Sep 19 '19 at 20:04
  • I have already latest version of pdo. But I run sudo apt-get install php-mysql. After this php artisan migrate command runs successfully with this warning: PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20170718/pdo_mysql.so.so (/usr/lib/php/20170718/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Migration table created successfully. – Amar Sep 19 '19 at 20:05
  • Hmm, remove `extension=pdo_mysql.so` and restart server then check. I think `sudo apt-get install php7.2-pdo` solved your problem. – Rashed Hasan Sep 19 '19 at 20:10
  • 1
    Problem finally solved. No warning/error occur this time. Migration runs successfully. – Amar Sep 19 '19 at 20:24
0
  1. Remove vendor folder and reinstall it using composer install
  2. update/install your php extensions (php-mysql, php-mbstring, php-pdo, php-dom)

Above two steps solved my problem.

Amar
  • 21
  • 5