.env file not updating in server? - laravel

After I uploaded my Laravel project in Cpanel I have to configure my env file according to my database.
I put database name, database user name and password also.
but after I save in the database and refresh my browser. it says
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO) (SQL: select * from sliders)
even though I have changed env file in server. but still showing me root#localhost.
Can't figure it out how to solve this.

run php artisan config:clear
mostly because of .env being cached

Related

Laravel app not connecting after deployment to live server

After deploying my Laravel app to inMotion hosting, I am having issues connecting to the database. What is strange is that if I use a PHP script to test the connection, it works. However, when trying to login I get this error:
SQLSTATE[HY000] [1045] Access denied for user #'localhost' (using password: YES) (SQL: select * from `users` where `email` = .com limit
I am using the exact same username and password in the .env file as I did in the PHP test script. I have tried clearing the cache and also changing the password for the database as well as my username.
Turns out it was the password in the .env file. It had special characters, so I had to add quotation marks around it.
Better if you can clear the config cache and see. You can use the following command to clear the config cache in Laravel:
php artisan config:cache

Why am i getting this error when i try to submit a form (Illuminate\Database\QueryException SQLSTATE[28000] [1045] Access denied for user)

enter image description here
why am i getting this error when i try to submit the contact form ?
And i get this issue only after hosting the website.
Website works fine in the local machine with contact form.
i changed the .env file according to the hosted db credentials.
Illuminate\Database\QueryException
SQLSTATE[28000] [1045] Access denied for user 'cargills'#'localhost' (using password: YES) (SQL: insert into
contacts (name, address, phone, email, subject,
division, message, updated_at, created_at) values (sadsa,
dfsdf, asdsad, dsfsd#asdfsa, Customer Enquiry, Exports, sadsad,
2020-02-21 11:27:32, 2020-02-21 11:27:32))
For some reason in your production you still try to connect to localhost (127.0.0.1).
Put the right ip in your env file to your host, check the port and then in the production console run:
php artisan config:cache so laravel get's the right credentials from your .env file.
There might be several reasons.
Your user and password is incorrect
User has not enough privileges to select or update that table
Incorrect hostname, sometimes changing DB_HOST to 127.0.0.1 solves that
Also make sure you don't have cached wrong/testing user and password
run
php artisan:cache clear
Then run:
php artisan config:cache
To cache new .env file
Hope this helps you

"SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' : Laravel 5.3

Hi I'm having a problem with laravel 5.3
project was moved from one host to another
and I've updated the .env file
The project was working well in the old host
but when I moved to the new host, the site displaying this error
1/2
PDOException in Connector.php line 119: SQLSTATE[HY000] [1045] Access denied for user 'xxxx'#'localhost' (using password: YES)
2/2
QueryException in Connection.php line 770: SQLSTATE[HY000] [1045] Access denied for user 'xxxx'#'localhost' (using password: YES) (SQL: select * from countries)
xxxx => The user name for the old database was not updated. i do not know the reasonenter image description here
There are many possible reasons to throw this exception, let's explore them:
There is a kind of cache in the .env file. In this case, you could only rewrite the DB variables, run php artisan config:clear and restart the server.
Maybe some of the DB variables aren't right. In this case, you could check out the values.
The user is right but he hasn't permission to access the database. In this case, you could check out the user permissions.
I hope that one of these tips help you.
Check the .env file it should include all value like CONNECTION, HOST, PORT, etc.
php artisan config:clear
composer dump-autoload and restart the server
the SQLSQLSTATE[HY000] [1045] seems like the password in your .env file doesn't match with the database's password.
You can check the database pass and user in the new server and put into your .env file.
Good luck

Laravel is using the default homestead user details to connect, even though these have been deleted

I am using laravel 5.8.6 and can connect to my database using the artisan migration tool, and can read and write to the database using tinker with no issues.
When I launch the default scaffolding it fails to connect, complaining that the login failed for user homestead#localhost.
I have deleted the .env.example file and cleared the various cache files with no success.
A full search for homestead only reveals log entries:
Illuminate \ Database \ QueryException (1045)
SQLSTATE[HY000] [1045] Access denied for user 'homestead'#'localhost' (using password: YES) (SQL: select * from `users` where `email` =
Any ideas gratefully received.
I had the exact same problem and I just couldn't wrap my mind around how that was even possible. Turns out I seem to have changed the .env file after having started the dev server via php artisan serve. It doesn't pick up changes in the .env config at runtime and it caches the configuration.
After running
php artisan config:clear
, shutting down the dev server and restarting it, the issue was resolved and the database connection successful with the correctly set database credentials.

SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)

I have uploaded my project on my hosting ..But when i tried to access form url I got the following Error
QueryException in Connection.php line 647:
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
I have changed the following credentials of .env
DB_DATABASE=cpanel_database
DB_USERNAME=cpanel_db_name
DB_PASSWORD=cpanel_db_password
What could be the error for getting the Above Error?
Just make sure your database credentials are correct.
Might be chance that configurations run from cache. once clear is by login in server via ssh or remove config.php file from bootstrap/cache/ folder.
Good luck.
Looks like it is not reading the credentials from your .env file. because it is reading root as the user instead of the username specified in the .env.
Check to make sure it is reading the .env and not the default parameters in the config/database.php file

Resources