简体   繁体   中英

Cannot migrate SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

I just cloned a website project on GitHub. When I want to migrate, an error like this appears. I have filled in DB_DATABASE and DB_USERNAME many times but it has no effect

.env

APP_NAME="Simple Company Profile"
APP_ENV=local
APP_KEY=base64:HLQuGR0tT28YYt4eg/GPPQpW4L+mii71zIx65nFNxDE=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=cms_pasti
DB_USERNAME=
DB_PASSWORD=

there is also a simple console here to create an admin account, but that also doesn't work在此处输入图像描述

I don't think that cloning a project will automatically replicate the database. You have to create it with a script/sql. Which should be part of the Github project.

So,

  • Either find the schema and create the database and tables manually.
  • Or find a sql backup and restore it

You have just cloned the repository but, that doesn´t mean that is ready to run. You have to create a database and connect with it.

Use PHPMyAdmin or any other Database management solution (HeidiSQL, MySQL WorkBench) in order to check if your Database credentials are working.

Another thing that is probably happening is that you have to create the database 'cms_pasti' first and then fill the.env:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=cms_pasti
DB_USERNAME=
DB_PASSWORD=

With the proper settings.

When done, you have to run in your console:

PHP artisan migrate

This command will do the migrations to build the database structure. But you have to be sure that the database is already created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM