1

When I run " php artisan migrate " in my project the following error occurs, How can I solve the error?

Illuminate\Database\QueryException
   
could not find driver (SQL: select * from information_schema.tables where table_schema = tc_cse-infohub and table_name = migrations and table_type = 'BASE TABLE')
    
      at F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
        708▕         // If an exception occurs when attempting to run a query, we'll format the error
        709▕         // message to include the bindings with SQL, which will make this exception a
        710▕         // lot more helpful to the developer instead of just the database's errors.
        711▕         catch (Exception $e) {
      ➜ 712▕             throw new QueryException(
        713▕                 $query, $this->prepareBindings($bindings), $e
        714▕             );
        715▕         }
        716▕     }
    ``
      1   F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70      PDOException::("could not find driver")
  
      2   F:\xammp\htdocs\github\TC_CSE-infoHub\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70      PDO::__construct()
    ```

Reahana
  • 11
  • 4

3 Answers3

0

It could be the wrong mysql port number in your .env file. Check your .env file and make sure the port number matches the same one mysql is using, also the SQL passwords in your env file, because the laravel framework is rejecting the connection hence the error on your screen.

Edit: If you're using windows make sure your php / db extensions are enabled on your xampp / wampp configurations.

For example: ;extension=pdo_mysql.so //uncomment this line just remove ;

after that please try again for php artisan migrate

Hassaan Ali
  • 1,038
  • 7
  • 16
0

You should install PDO on your server. Edit your php.ini (look at your phpinfo(), "Loaded Configuration File" line, to find the php.ini file path). Find and uncomment the following line (remove the ; character):

;extension=pdo_mysql.so

After this restart the server and should be good to go.

Edit:

composer update

composer require doctrine/dbal

php artisan cache:clear
php artisan view:clear
php artisan route:clear

Check your .env file

  DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=dbname
  DB_USERNAME=username
  DB_PASSWORD=password

run php -m and see if it lists pdo

Kevin
  • 1,152
  • 5
  • 13
0

Firest of all, adding phpinfo to your code path find out your php.ini location

    <?php
phpinfo(); 
?>

enter image description here

Since you have already uncommented MySQL extension, make sure to uncomment extension=php_pdo.dll as well in the php.ini and restart the Apache. Before migration, make sure to run

 php artisan cache:clear 
 php artisan view:clear 
 php artisan route:clear
Shamith Wimukthi
  • 468
  • 3
  • 12