In the past few days, learning the Laravel framework encountered database problems.
PDOException in Connector.php line 55:SQLSTATE[HY000] [1045]
Access denied for user 'homestead'@'localhost' (using password: YES)
The solution to the problem is as follows
1. Confirm that the database.php file is configured correctly.
First check that the information you filled in database.php is correct.
2. Check the .env file
This is the default .env file
APP_ENV=local
APP_KEY=
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=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
Take part corresponding database
I use the mysql database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
3. Modify the .env file
Modify the above part as follows
DB_CONNECTION=mysql
DB_HOST=[your db adress]
DB_PORT=[port(3306)]
DB_DATABASE=[db]
DB_USERNAME=[username]
DB_PASSWORD=[password]
Save after modification
4. Restart the service
The initial change was unsuccessful, and it took a long time to find that the cache was not cleared. . .
Clean the cache to restart the service
into the root directory on the command line, issue the following statement.
php artisan cache:clear
php artisan config:clear
php artisan serve
This is enough to refresh.
Similar Posts:
- When laravel is uploaded to the server, whoops, looks like something went wrong appears
- [Solved] Laravel Groupby error: laravel which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
- Phpmailer’s solution to extension missing: OpenSSL error
- Laravel Syntax error or access violation: 1055 ‘***’ isn’t in GROUP BY
- MySQL database insert into statement with parameters Error
- [Warning] Using a password on the command line interface can be insecure. (Solved)
- [Solved] Lavarel execution: PHP artisan migrate reports an error
- When executing the vacuum SSH command, ‘SSH’ executable not found in any directions in the% path%. Solution to the prompt
- MySQLAccess denied for user ‘root’@’localhost’ [How to Solve]
- [Solved] Error when connecting to MySQL when creating Django project