skip to Main Content

I need a lot of help, I’m trying to upload my Laravel 9 project to my server but I always get this error,

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

I already configured the .env I already configured the database file in code, on my server I have everything configured correctly and I still get the same error, I tried with another project and it works but with this one I always get this error and I don’t know why

2

Answers


  1. From your error message ... using password: NO it seems you have not set DB_PASSWORD in .env. Also specify what database server you are using.

    To verify your configuration is correct then run php artisan tinker in production server and type config('database') and see the results. If you want you can post them here but replace password, host with xxx.
    If you do not have terminal access in production then create a route with clojure with dd( config('database')) and see the data for the appropriate database connection you are using. Keep in mind you have to immediately remove this route so you info are not exposed to the world.
    Also, in case your database server is in another host then make sure database allows connections from other hosts.

    Login or Signup to reply.
  2. If you have access to the server’s terminal, run php artisan optimize.

    If you don’t, you can use Artisan facade. there’s two way to clear out caches.

    Option 1 (using Artisan facade):

    You can call it at the beginning of the routes file or a controller method like this:

    IlluminateSupportFacadesArtisan::call('config:clear');
    

    The above command will clear the config’s cache.

    Also, for routes, you can use the below command:

    IlluminateSupportFacadesArtisan::call('route:clear');
    

    Option 2 (delete cache files):

    Another way is to delete all files in bootstrap/cache folder.

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