arun3x3's avatar

[PDOException] SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'-Homestead

I was able to successfully create migrations from Xampp. However when i installed Homestead(vagrant,Virtual Box) and try to associate it with a database and run migrations i am facing

  [PDOException]
  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

I have literally tried many configurations for .env file and config/database file , none seems to be working.

APP_ENV=local
APP_KEY=base64:AxtpwFxTGQ3tkumIu1nkzswrTbuI37BigLGn3meRC6M=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lara56
DB_USERNAME=root
DB_PASSWORD=

My config file

 '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', 'lara56'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
0 likes
4 replies
jlrdw's avatar

Doesn't that box have its own MySQL you may need to import an SQL dump.

tomopongrac's avatar

You must excute migration from host machine (connect to homestead with ssh)

arun3x3's avatar

From my knowledge we get a default mysql db of "homestead" with password "secret". Do we have a way to access these database like we do for mysql database.

arun3x3's avatar

@tomi i did execute migrations from SSH as you mentioned.

Vagrant up
vagrant ssh
laravel new blog3

Then first time i executed without changing .env file. i got the result

nothing to migrate

once i changed .env file settings , created empty database so that in mysql (xampp).

  [PDOException]
  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

Please or to participate in this conversation.