简体   繁体   中英

Why am I getting a Laravel php artisan migrate error?

I am new to Laravel and am trying to follow along with an online tutorial. I came to a point where I need to run php artisan migrate in the terminal and I get the following error:

  Illuminate\Database\QueryException 

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

  at C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669
    665|         // If an exception occurs when attempting to run a query, we'll format the error
    666|         // message to include the bindings with SQL, which will make this exception a   
    667|         // lot more helpful to the developer instead of just the database's errors.
    668|         catch (Exception $e) {
  > 669|             throw new QueryException(
    670|                 $query, $this->prepareBindings($bindings), $e
    671|             );
    672|         }
    673| 

  1   C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=some_db", "root", "", [])

I've tried every solution I could find on here and I've gone into my php.ini file to enable different extensions but nothing seems to work. I found a solution that said to try running sudo apt-get install php-mysql but I'm using Windows so that's not an option for me. Any help on this matter would be greatly appreciated!

If you already have the mysql driver installed, you should make sure that the following variables are assigned in the .ENV file// Si ya tienes el controlador para mysql instalado, debes asegurarte que en el archivo .ENV estén las siguientes variables asignadas:

DB_CONNECTION=mysql //mysql driver
DB_HOST=127.0.0.1   //connection host
DB_PORT=3306        //mysql port
DB_DATABASE=laravel //database name
DB_USERNAME=root    //database user
DB_PASSWORD=        //database password

In your php.ini configuration file simply uncomment the extension:

;extension=php_pdo_mysql.dll

( You can find your php.ini file in the php folder where your stack server is installed. )

If you're on Windows make it: extension=php_pdo_mysql.dll

If you're on Linux make it: extension=pdo_mysql.so

And do a quick server restart.

If this isn't working for you, you may need to install pdo_mysql extension into your php library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM