[英]Laravel Sail Error 1045 Access denied for user
I'm using Laravel Sail for the first time and having trouble getting mysql to work.我第一次使用 Laravel Sail 并且无法让 mysql 工作。 My
.env
file contains:我的
.env
文件包含:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=appname
The front end of my application shows:我的应用程序的前端显示:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `sessions` where `id` = oH7qa1x3OqqhKFpme3ewLzgEeVC9VL3BYFRQCjW1 limit 1)
Whenever I run ./vendor/bin/sail mysql
in terminal, I get:每当我在终端运行
./vendor/bin/sail mysql
时,我得到:
ERROR 1045 (28000): Access denied for user
Have I missed something really obvious?我错过了一些非常明显的事情吗?
Before we try the potential fix.在我们尝试潜在的修复之前。
Run docker ps -a
which will also work for sail, find the container named sail_mysql / mysql anything similar, and copy the container id.运行
docker ps -a
这也适用于sai,找到名为sail_mysql / mysql 的容器,并复制容器ID。
Now paste docker logs CONTAINER ID
现在粘贴
docker logs CONTAINER ID
To see if you see any specific errors, maybe this will narrow down what's going wrong.要查看您是否看到任何特定错误,也许这会缩小出现问题的范围。
Without further logs and based on my personal experience with Sail I'm going to assume you've tried to start your mysql container against a pre-existing volume already containing a mysql database.在没有更多日志的情况下,根据我对 Sail 的个人经验,我假设您已尝试针对已经包含 mysql 数据库的预先存在的卷启动 mysql 容器。
Quoting the docker documentation:引用 docker 文档:
Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.
请注意,如果您使用已包含数据库的数据目录启动容器,则以下任何变量都不会产生任何影响:任何预先存在的数据库在容器启动时将始终保持不变。
Rebuild from scratch, warning: this will erase everything in your current database.从头开始重建,警告:这将删除当前数据库中的所有内容。
sail down -v
sail up -d
Hope I've been able to help.希望我能提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.