Laravel Connection Database error occurred
Pdoexception in connector.php line 55:sqlstate[hy000] [1045] Access denied for user ' homestead ' @ ' localhost ' (using passwor D:yes)
1. Confirm./config/database.php
<?phpreturn [ ' Default ' = env (' db_connection ', ' MySQL '), ' connections ' = [ ' SQLite ' = [ ' driver ' = ' sqlite ', ' database ' = env (' Db_database ', Database_path (' Database.sqlite ')), ' Prefix ' + ', ], ' mysql ' = [ ' driver ' = ' mysql ', ' host ' = ' env ' (' db_host ', ' 127.0.0.1 '), ' c10/> ' Port ' = env (' Db_port ', ' 3306 '), ' database ' = env (' db_database ', ' studyonline '), ' username ' = > env (' Db_username ', ' root '), ' password ' = env (' Db_password ', '), ' unix_socket ' = env (' Db_ SOCKET ', '), ' charset ' = ' utf8 ', ' collation ' = ' utf8_general_ci ', ' prefix ' and ' = ', ' Strict ' = true, ' engine ' = null, ], //... ]
2. Check the. env file
Errors caused by the default configuration
db_database=Homestead
Db_username=Homestead
Db_password=Secret
App_name=laravelapp_env=localapp_key=base64:cdqloknt6jfruiwfabq/rqdur42lgfi8qcc5b4r/ksi=app_debug=trueapp_url= Http://localhostLOG_CHANNEL=stackDB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=studyonlineDB_ username=rootdb_password=
3. Restart the service
PHP Artisan cache:clearphp Artisan config:clearphp Artisan Serve
CD./publicphp-s localhost:9000
Laravel Artisan Some commands
* Create model
PHP Artisan Make:model Video
Generated after execution./app/video.php
<?phpnamespace app;use illuminate\database\eloquent\model;class Video extends model{ //}
* Create Controller
PHP Artisan Make:controller Usercontroller
Generated after execution./app/http/controllers/usercontroller.php
<?phpnamespace app\http\controllers;use Illuminate\http\request;class Usercontroller extends Controller {}
Laravel [1045] Access denied for user ' homestead ' @ ' localhost '. ENV Not Configured