skip to Main Content

I’m currently working on a Laravel project. I did the deploy on a shared server, but I get the error message

“SQLSTATE [HY000] [1045] Access denied for user ‘root’ @ ‘localhost’ (using password: NO)”

The project in Local works me correctly, but on the server it’s limited to error only. I configured the environment variables in my .env

I think that the server probably does not read the .env file and that is why the problem arises.

3

Answers


  1. Chosen as BEST ANSWER

    Actually the problem was with my Hosting.

    My best option was to start using DigitalOcean.

    But at that moment what I did was:

    • Create a new database.
    • Create a new user.
    • Add the new data in my .env file as specified by Laravel.
    • Create a route to clear the cache as Junaid Ahmad specified but by changing some things.

    Route::get('/cache', function() { $clear = Artisan::call('cache:clear'); return "Cache cleared"; });

    I take this opportunity to thank those people who helped me at that time.

    And if you are going through this: Avoid at all costs modifying the database.php file. This isn't a good practice... And change your hosting for a DigitalOcean VPS.


  2. Clear your cache on live server by adding and running this route:

    Route::get('/clear-cache', function() {
        $exitCode = Artisan::call('cache:clear');
        // return what you want
    }); 
    
    Login or Signup to reply.
  3. You have to add your proper database credentials to .env file .. you can find the database credentials in cPanel

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search