N
N
Nikita Filatov2015-08-15 09:36:03
MySQL
Nikita Filatov, 2015-08-15 09:36:03

How to fix Access denied for user... error in laravel homestead?

Laravel throws an error when trying to migrate to the framework

[PDOException]                                                               
  SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (usin  
  g password: YES)

Googling, I realized that this error indicates that the UserName or Password items are not entered correctly. Here is the .env file itself, which configures the connection to the database, where all the data is entered as written in the documentation:
APP_ENV=local
APP_DEBUG=true
APP_KEY=JLCGJP1CiFpI24q50pZAZOTNRcl1eRCr

DB_HOST=127.0.0.1      
DB_DATABASE=homestead   
DB_USERNAME=homestead    
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

tried to connect to the database via MySQL WorkBrench - everything connected fine.
09df406b8c8246df8f1ba66868452570.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dashunia, 2019-07-08
@Dashunia

Look at the settings in the config\database.php file:

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            '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' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question