0

I am unable to launch the homestead in the database of Laragon. It gives me the following error.

"SQLSTATE[HY000] [1045] Access denied for user 'root'@localhost'

Also, can anyone explain to me how to connect the MySQL server to Laravel from laragon terminal?

Thanks in advance.

Ankur Tiwari
  • 2,762
  • 2
  • 23
  • 40

2 Answers2

1

You can set Database connectivity in .env file in laravel

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root // username 
DB_PASSWORD="" // password

Or you can set it from path :- /app/config/database.php

'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

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

    ],
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40
0

Go To Your Root you-project-name/ folder you will find .env file there edit your Db credentials in that file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=YOU-DB-NAME
DB_USERNAME=USER-NAME
DB_PASSWORD=PASSWORD

and then try again this command

Arbaz Khan
  • 80
  • 8