Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB connection failed #348

Open
gkjangid opened this issue Jul 7, 2020 · 5 comments
Open

DB connection failed #348

gkjangid opened this issue Jul 7, 2020 · 5 comments

Comments

@gkjangid
Copy link

gkjangid commented Jul 7, 2020

My .ENV file
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=gitscrumorion
DB_USERNAME=gitscrumorionkp
DB_PASSWORD=gitscrumorionkp_321

But Db connected
Screenshot from 2020-07-07 11-59-50

@nyrnzn
Copy link

nyrnzn commented Jul 7, 2020

@gkjangid can you show the content of your database.php file in the config folder?

@gkjangid
Copy link
Author

gkjangid commented Jul 7, 2020

Database.php

'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('gitscrumorion'),
        'username' => env('gitscrumorionkp'),
        'password' => env('gitscrumorionkp_321'),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ]

],

@nyrnzn
Copy link

nyrnzn commented Jul 7, 2020

Update your database.php file to this:

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => env('DB_PREFIX'),
            'strict' => false,
            'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
        ],

You should not be changing anything on this file.

Basically, what happens is, in this statement, for example,
'database' => env('DB_DATABASE', 'forge'),
env() takes two parameters,

  • Name of the environment variable in your .env file
  • Default value if the environment variable cannot be found.

Database.php

'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('gitscrumorion'),
        'username' => env('gitscrumorionkp'),
        'password' => env('gitscrumorionkp_321'),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ]

],

@gkjangid
Copy link
Author

gkjangid commented Jul 7, 2020

@nyrnzn Thanks dear
But now i have some other issue
i have only 14 tables are come
Screenshot from 2020-07-07 15-24-47
Screenshot from 2020-07-07 15-25-01

@armsasmart
Copy link

you can add like this.

https://laravel.com/docs/8.x/migrations#indexes

AppServiceProvider.php

use Illuminate\Support\Facades\Schema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants