Search code examples
phplaravellaravel-artisanmigrate

PHP artisan migrate exception


I am new to php laravel and got an issue that I cannot solve. Please advise me. When I run 'php artisan migrate', I get a QueryException saying:

Could not find driver (SQL: PRAGMA foreign_keys = ON;)

I have tried adding extension=php_pdo_mysql.so to my php.ini because it was not there but it did not work

This is the error message I get: QueryException

Thanks very much


Solution

    1. Ensure you have php7.0-mysql installed.
    2. uncomment extension=php_pdo_mysql.so;
    3. Ensure you have your database environment variables configured properly to connect to your mysql database. Something like this in your .env file.

      DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database_name DB_USERNAME=database_username DB_PASSWORD=database_password