0

I have been trying to run migration since yesterday but database connection is preventing it Note: I can access the database very well from other projects. This only happens with laravel on homestead. Here is the output of the php artisan migrate command:

SQLSTATE[HY000] [1045] Access denied for user 'abdellah'@'192.168.10.10' (using password: YES) (SQL: select * from information_schema.tables where table_schema = furbook and table_name = migrations and table_type = 'BASE TABLE')

This is my .env database config

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=furbook
DB_USERNAME=abdellah
DB_PASSWORD=bonjour1

And this is the database.php file

      'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'furbook'),
            'username' => env('DB_USERNAME', 'abdellah'),
            'password' => env('DB_PASSWORD', 'bonjour1'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

I am running on Homestead environment. Thanks.

  • 1
    Possible duplicate of [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – aynber Oct 15 '19 at 12:27
  • @aynber I can access the database from other projects. Only Laravel on homestead refuses to connect. –  Oct 15 '19 at 12:31
  • This might be stupid, but are you sure you're running the migrate command inside the Homestead virtual box? I mean after `vagrant ssh`? – Salim Djerbouh Oct 15 '19 at 12:59
  • @Saly3301 yes I have ssh into the box and I am running from the virtual machine. –  Oct 15 '19 at 13:28

2 Answers2

0

Have you made sure everything is spelled correctly?

The only other thing I can think of is adding an extra 0 at the end of the port (DB_PORT=33060).

It's weird but I had a fresh Laravel project using homestead and the only way I could access the DB artisan commands in the terminal was to add a 0 on the port but then I had to take it off again once accessing it through HTTP.

Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
0

I was able to run the migration successfully by setting the DB username to homestead and DB password to secret.

DB_USERNAME=homestead
DB_PASSWORD=secret