Solved: No Driver Found Error in Laravel Migration!


 How to solve error could not find driver while migrating files in Laravel


In this article we will see how to fix a very common error we get while migrating our files in Laravel that is " could not find driver " when you runs php artisan migrate the actual error look something like below .


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

Could not find driver while migrating in Laravel - FIXED

So, now we will see how to fix this error . I will provide you 2 solution for this error and i have tested these solutions on my ubuntu system . so i am not sure whether this solution will work for windows or any other operating system and it depends which solution will work on your system because for me solution-2 worked perfectly . 

So first try solution-1 , if error not fixed then try solution-2 .

Solution -1 : change php configuration

Solution - 1 is to change our php configuration in your php.ini file as shown below .

Go to your php.ini file :

Go to your php.ini file . If you don't know where is your php.ini file located then simply run the following command on command prompt and you will get the path detail of your php.ini file .

php -i

Could not find driver while migrating in Laravel - FIXED

Change configuration :

On your php.ini file search for extension=pdo_mysql   and simply uncomment it by removing semicolon (' ; ') before it .

Now again run php artisan migrate  and now your error " could not find driver " should be fixed . If this solution does not work please follow the solution - 2 .

Solution - 2 : Install Dependencies

Implement Solution 1 :

For solution 2 , first implement solution 1 ( uncommnet extension=pdo_mysql in php.ini file ) .

Install Dependencies :

So after completing solution 1 , we have to install MySQL using the following steps and restart your apache server . 

In my case i have already installed MySQL but still i ran these following command again and the error was gone for me .

First check your php version by php -v and install mysql as per your php version by the following command .

php 7.0 sudo apt-get install php7.0-mysql

php 7.1 sudo apt-get install php7.1-mysql

php 7.2 sudo apt-get install php7.2-mysql

php 7.3 sudo apt-get install php7.3-mysql

Then simply restart your apache server by the following command .

sudo service apache2 restart

or if you are using XAMPP / WAMPP / LAMPP simply stop and start your apache server again .

Now run your migration command ( php artisan migrate )  . It should resolve your error .

Post a Comment

Post a Comment (0)