0

I'm having the following error : SQLSTATE[22023]: Invalid parameter value: 7 ERROR: invalid value for parameter "client_encoding": "utf8mb4" (SQL: select exists(select * from "oauth_personal_access_clients") as "exists")

$token = Auth::user()->createToken('api')->accessToken;

Of course, i'm using heroku with pgsql, and my db configuration =>

    'default' => env('DB_CONNECTION', 'pgsql'),

  'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

The database works fine, except for this case.

1
  • Your config charset utf8 but your inserted field charset is utf8mb4 may be you edit recently, then reboot your server
    – STA
    Jul 31, 2020 at 23:39

3 Answers 3

0

I've solved it. In passport.php

    /*
    |--------------------------------------------------------------------------
    | Passport Storage Driver
    |--------------------------------------------------------------------------
    |
    | This configuration value allows you to customize the storage options
    | for Passport, such as the database connection that should be used
    | by Passport's internal database models which store tokens, etc.
    |
    */

    'storage' => [
        'database' => [
            'connection' => env('DB_CONNECTION', 'mysql'),
        ],
    ],

];

I change it to :

  'connection' => env('DB_CONNECTION', 'pgsql'),

and then php artisan migrate. And it works!

0

where is the file to do that?? (Passport Storage Driver). Thanks

0

The file passport.php is generated by running php artisan vendor:publish --tag=passport-config. This information is very difficult to find and it should be mentioned in the original answer (which is correct).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.