-2

When I migrate my tables using the php artisan migrate command I get the following error :

Illuminate\Database\QueryException : could not find driver (SQL: select * from i nformation_schema.tables where table_schema = test and table_name = migrations and t able_type = 'BASE TABLE')

Sorry if this is an easy fix but I'm really new to using Laravel so this has me scratching my head and I don't really understand what is causing the error

Vincent Decaux
  • 9,857
  • 6
  • 56
  • 84
the_wiganer
  • 1
  • 1
  • 2
  • Just copy / paste your error in Google, you will find answers, for example : https://stackoverflow.com/questions/46745365/artisan-migrate-could-not-find-driver?rq=1 – Vincent Decaux Jul 09 '19 at 10:31
  • Possible duplicate of [Artisan migrate could not find driver](https://stackoverflow.com/questions/46745365/artisan-migrate-could-not-find-driver) – Salman Zafar Jul 09 '19 at 10:32
  • All the solutions point to editing a file called php.ini which I don't have in my directory so I'm lost here – the_wiganer Jul 09 '19 at 10:34

1 Answers1

0

What driver are you using for your database?

(I'm assuming you're on linux or mac and are running your migrations from your host machine and not while SSH'd into your Vagrant Box or similar)

If it's MySQL:

Find PHP config file:

$ php -i | grep -Ei php.ini

Output:

Configuration File (php.ini) Path => /etc/php
Loaded Configuration File => /etc/php/php.ini

$ sudo nano /etc/php/php.ini

Then press ctrl+W to search, type mysql and hit enter.

You should see the extensions list, in there remove the ; infront of extension=pdo_mysql

Now run $ php -v

And if you see something along the lines of "Extension pdo_mysql.so not found". (You may need pdo_pgsql or pdo_sqlite3, depending on the driver you're running)

You just need to install the correct version of php-mysql for your PHP installation.

Your $ php -v output should show the version of PHP you're running.

Once the output of $ php -v shows no errors, you should be good to go.

stokoe0990
  • 443
  • 3
  • 10
  • When I search for mysql in the php.ini file I get "mysql" not found which doesn't make sense to me because I know I have mysql installed on this machine. Thanks for your patience btw – the_wiganer Jul 09 '19 at 10:43
  • Try scrolling through the file to find the list of lines that start `;extension=...` Add `extension=pdo_mysql` to the end of the list. – stokoe0990 Jul 09 '19 at 12:48