我已经在我的机器上安装了 homestead 并从远程存储库克隆了一个项目,现在我正在尝试为我的项目创建一个数据库。 这是我的 .env 文件的样子:
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:e7K7SUDgogNqTtP9TO1CfpbXFAC6FmLLSJ1l6K8pbWs=
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
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
我尝试使用 sequel pro 标准选项连接到数据库:
Host: localhost
Password: secret
但是我得到:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)
我做错了什么?
最佳答案
一些选项:
- 检查mysql服务是否正在运行;
- 检查用户和密码是否正确;
- 检查用户的权限,试试
root
用户
关于database - Laravel/Homestead - 无法连接到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44630430/