0

I've set up a new project in Laravel 8 (I've fairly new to Laravel) and done the following:

  1. Created a DB called 'firstproject'
  2. Installed Laravel and run php artisan ui:auth
  3. Update my .env file
  4. When I run php artisan migrate I get the following error:
 Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = firstproject and table_name = migrations and table_type = 'BASE TABLE')

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

      +33 vendor frames 
  34  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

My .env file has the following:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=firstproject
DB_USERNAME=root
DB_PASSWORD=/* Password here */

I'm struggling to get past this issue and would greatly appreciate any help.

Thanks in advance

  • I've seen this error with MySQL 8 when you're using `root` without a password: https://stackoverflow.com/questions/52364415/php-with-mysql-8-0-error-the-server-requested-authentication-method-unknown-to. Is this your problem? Also, did you try Googling that error message? You're not the first person to encounter this issue :) – Tim Lewis Dec 02 '20 at 15:43
  • 1
    Thanks, I'll have a look at that link to see if that helps. I've got a password in my .env file but I removed it from the question I posted. I'll let you know if that question helps solve my issue. – greenGreenGrass Dec 02 '20 at 16:13
  • @TimLewis I've tried updating the password using the 'ALTER USER' command and then Flush Privileges but I'm still getting the same error. – greenGreenGrass Dec 02 '20 at 17:01
  • Hmm, interesting. If you run `php artisan tinker`, then `env('DB_PASSWORD')`, does it show your configured password or `null`? – Tim Lewis Dec 02 '20 at 17:04
  • 1
    I've tried that and it does show the correct password. I spent a good amount of time trying to see if I can figure this out and fix it but I'm thinking I might need to uninstall and reinstall mySQL just in case there's an issue with the config – greenGreenGrass Dec 03 '20 at 16:11

0 Answers0