Laravel [1045] Access denied for user ' homestead ' @ ' localhost '. ENV Not Configured

Source: Internet
Author: User
Tags sqlite

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.