Database not configured laravel during migration

前端 未结 4 1303
南旧
南旧 2021-01-12 03:43

This might be repeated question. But I had no luck with previous answers

I just git clone a laravel project. Now I tried to do php artisan migrate

相关标签:
4条回答
  • 2021-01-12 04:04

    Another solution which worked is to cache config: php artisan config:cache like here

    0 讨论(0)
  • 2021-01-12 04:09

    Just remove .env file and put new to replace

    0 讨论(0)
  • 2021-01-12 04:19

    I had the same issue. I have cloned the L5.1 project from GIT and i performed

    composer install 
    composer update 
    

    and also configured DB details in .env (by default .env is not present so i took the copy of .env.example and renamed as .env). After that if tried to run

     php artisan migrate
    

    I got the same exception like as @users4393829 mentioned. I tried follow commands to find and set the database.

     php artisan tinker
     >>> Config::get('database.connections.mysql.database');
     >>>null
     >>>Config::set('database.connections.mysql.database','homesteaed');
     >>>Config::get('database.connections.mysql.database');
     >>>homesteaed
    

    After doing all this things i found that there is no database.php file so i have placed it in the 'config' folder and ran the migration it works. Please make sure that you have any config files is git ignored in your project.

    0 讨论(0)
  • 2021-01-12 04:21

    I had the same problem, turns out the .env that shipped with the framework defaulted the DB_HOST to localhost and had DB_PORT set.

    Changed the host to the FQDN of the machine and it worked fine. I'm guessingif you're connecting to localhost it expects a socket and not a port.

    0 讨论(0)
提交回复
热议问题