Laravel 'could not find driver (SQL: insert into...'

18,530

What lines did you uncomment in php.ini file?

Do you have the pdo_mysql extension installed?

Remove the ; from ;extension=pdo_mysql.so and restart your WAMP server

Source: https://stackoverflow.com/a/35240511/6385459

Share:
18,530
Vranvs
Author by

Vranvs

Updated on June 04, 2022

Comments

  • Vranvs
    Vranvs almost 2 years

    I'm trying to set up a development environment after not having done web dev in over a year. I've installed php 7.2.7 on my computer, then installed composer and WAMP.

    I'm using php artisan serve to set up a local server. I'm trying to create a new user in my database's 'users' table, using the following code in my web.php (routes) file.

    Route::get('/new', function(){
      User::create([
        'password' => Hash::make('anything'),
        'firstname' => 'Nick',
        'lastname' => 'xyz',
        'email' => '[email protected]',
        'roleflag' => 0
      ]);
    });
    

    But am getting the following error:

    enter image description here

    This seems to be a pretty common error, and I have found help on other stackoverflow/laracasts posts such as:

    Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

    and

    https://laracasts.com/discuss/channels/general-discussion/cant-connect-to-sql-server-could-not-find-driver

    I've thus uncommented the two lines from my php.ini file, changed my .env and config/database.php file to have appropriate settings/connection values, etc. but still receive this error.

    Relevant config.php code:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('venturebreeder', 'forge'),
        'username' => env('root', 'forge'),
        'password' => env('', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],
    

    I'm a bit slower at troubleshooting since it has been a while since I've done this -- can anyone see what I'm doing wrong? Help much appreciated.

    • Raymond Nijland
      Raymond Nijland almost 6 years
      Normally you are busted when you upload a password "hash". But this looks to be PHP's hash with blowfish encryption.. PHP call's it a hash but blowfish is really a cypher.. Geuss because it's blowfish you are alright because rainbow tables does not work and bruteforce is also pretty impossible because password_hash generates a different password every time sandbox.onlinephpfunctions.com/code/…