1

I have a problem with laravel 5.4 conection with database. I made changes in cofig/database file and when I try to migrate I recive 1045 error.

>  'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'laravel'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

I aslo cant find my .env file and when I wanna crate it I receive message that file exists.Where can I find it?

Unamata Sanatarai
  • 6,475
  • 3
  • 29
  • 51
mihighlo
  • 11
  • 2

3 Answers3

0

Since your .env file exists, it means Windows is hiding it from you (for some reason).

Have you tried opening the file in notepad++ for example? (ctrl+o + type in .env)

It looks like your settings in the .env file are incorrect. So if you'd like to skip loading data from it, do not use the env() method, as it loads data from .env file.

Try this:

'mysql' => [
            'driver' => 'mysql',
            'host' => '127.0.0.1',
            'port' => '3306',
            'database' => 'laravel',
            'username' => 'root',
            'password' => '',
            'unix_socket' => '',
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
Unamata Sanatarai
  • 6,475
  • 3
  • 29
  • 51
0

Since you have already got your answer but if you don't find an empty file in your root folder, then you can use *php artisan key:generate* on your terminal which will generate an app key and a env file if it doesn't exits.

Saurav
  • 355
  • 1
  • 3
  • 13
0

same problem i got regarding .env, i was using sublime text and .env file was hidden. i do refresh the IDE and reopen my project and i found it. similarly it happened to Netbean IDE too, just refresh it and it works. Your problem is not regarding your database connection, its about the length of the user email, you need to define its length by 191. goto your project app/providers/appserviceprovider.php file and add this line use Illuminate\Support\Facades\Schema; and inside the method boot() add this line Schema::defaultStringLength(191); and type php artisan migrate, it will work cool. goto this https://laravel-news.com/laravel-5-4-key-too-long-error

Y. Joy Ch. Singha
  • 3,056
  • 24
  • 26