当我尝试执行php artisan migrate
时,我得到以下内容:
在
Connection.php
第647行:SQLSTATE [HY000] [2002]拒绝连接 (SQL:select * from information_schema.tables where table_schema = cotacao_job and table_name = migrations
)APP_NAME = Laravel APP_ENV =本地 APP_KEY = BASE64:Ciz4TWDongGPodaNDo9wcxJh48A / af6JwWWE3 / ydPkI = APP_DEBUG = true APP_LOG_LEVEL = debug APP_URL = http://localhost/work-cotation-service/
DB_CONNECTION = mysql DB_HOST = 127.0.0.1 DB_PORT = 33060 //我试过3360 DB_DATABASE = homestead DB_USERNAME = homestead DB_PASSWORD = secret
BROADCAST_DRIVER = log CACHE_DRIVER = file SESSION_DRIVER = file SESSION_LIFETIME = 120 QUEUE_DRIVER = sync
REDIS_HOST = 127.0.0.1 REDIS_PASSWORD = null REDIS_PORT = 6379
MAIL_DRIVER = smtp MAIL_HOST = smtp.mailtrap.io MAIL_PORT = 2525 MAIL_USERNAME = null MAIL_PASSWORD = null
它在一个新的家园5.1
答案 0 :(得分:1)
如果您不使用.env
config/database.php
文件或.env
中配置与数据库的连接
答案 1 :(得分:1)
当您使用宅基地时,需要在ssh之后而不是在普通控制台中的游荡框中运行以下命令 只需按照以下步骤操作即可。
1. ssh into your homestead using below command
2. cd ~homestead (where you set up your virtual box)
3. vagrant up
4. vagrant ssh
5. cd Code/PATH_TO_YOUR_APP_ROOT_DIR
6. php artisan migrate
答案 2 :(得分:0)
我认为问题的出现只是因为您没有在.env文件中设置数据库详细信息,所以请更新它,否则您也可以通过更新config / database.php中的详细信息来配置它。
对于.env文件
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=