HUGE_DICK_10_INCHES's avatar

Laravel works with non existing database

I noticed a problem with my local app, It worked for some time but recently uploading images stopped working. It does upload but nothing shows on frontend. Now I did direct change in database, the only one I have on my machine. I added new row in users table, but when I use php artisan tinker with App\User::all() I get only few from before, not recently added ones.

My .env has this:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=final
DB_USERNAME=root
DB_PASSWORD=

And config/database.php has env values to these from above. I also tried disconnecting from internet. I am totally blind. There is no other database on my xampp folder, nor other mysql installations. Not even sqlite files.

Can I somehow reset database?

When I run \DB::getDatabaseName() I get database/database.sqlite that does not exist....

0 likes
3 replies
jlrdw's avatar

Use artisan command and clear all cache, and then try restarting servers. May or may not help. But if you haven't changed any main database settings, all should still be working.

Check all error logs, including the Apache error log, it usually reveals a lot.

OriOn's avatar

Hello, Is the config/database.phpfile also reading the .env file?

...
'default' => env('DB_CONNECTION', 'mysql'),
... 
'connections' => [
            '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' => '',
            'strict' => true,
            'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
        ],
...

munazzil's avatar

Have you tried key generate command in cmd?

    php artisan key:generate

Please or to participate in this conversation.