-1

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!

Al-byte
  • 47
  • 1
  • 6
  • first do you have created .env on root ? do you have mysql installed ? did you run `php artisan clear` – Burhan Ibrahimi Mar 27 '20 at 20:40
  • I have the .env file that came with the laravel package and I have mysqli that I use with phpmyadmin. I just ran `php artisan clear` but it didn't fix my problem. – Al-byte Mar 27 '20 at 20:50

2 Answers2

0

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
0

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.

long-blade
  • 721
  • 1
  • 5
  • 9