Laravel Database name error seems incorrect how to resolve?

Asked

Viewed 606 times

-2

I recently created a Previder service, which kind of works. however when I will capture the database data using Produtos::all(); I get the following error:

Database name seems incorrect You’re using the default database name Laravel. This database does not exist.

Edit the . env file and use the correct database name in the DB_DATABASE key.

the data in the ENV file:

DB_CONNECTION=mysql
DB_HOST=tommy.heliohost.org
DB_PORT=3306
DB_DATABASE=ricmlima_site
DB_USERNAME=ricmlima
DB_PASSWORD=*******

/config/database.php

'default' => env('DB_CONNECTION', 'mysql'), 
'connections' => [ 'mysql' => [
    'driver' => 'mysql',
    'url' => env('DATABASE_URL'),
    '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' => '',
    'prefix_indexes' => true,
    'strict' => true,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
         PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],  
],

I have already tried to remove the default data in the /config/database.php file

        'host' => env('DB_HOST', 'tommy.heliohost.org'),
        'database' => env('DB_DATABASE', 'ricmlima_site'),
        'username' => env('DB_USERNAME', 'ricmlima'),
        'password' => env('DB_PASSWORD', '********'),

But you didn’t solve it. what I do ?

  • 1

    Have you tried switching the host to localhost rather than tommy.heliohost.org ? Since the application is hosted on that server will probably work like this.

  • 1

    :D I have the application running locally. with external database. @Laérciolopes . However, I just solved it. Redoing the Laravel cache. Thank you very much.

1 answer

1


The solution to this problem was to cache the Laravel:

php artisan config:cache

immediately became perfect.

  • 1

    Interestingly, php Artisan optimize:clear did not clear the settings, but php Artisan config:cache, yes!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.