0

I moved my website to a new server and :

1- Changed database connection app/etc/env.php

2- Cleared the cached files in "/var/cache", "/var/page_cache", "var/view_preprocessed","/var/composer_home", "/var/generation"

and i still got the following error:

Error!: SQLSTATE[HY000] [1045] Access denied for user 'USER_XXXX'@'localhost' (using password: YES)

Note: USER_XXXX is my old database user not the new one which is in my env file

Edit:

while runing the following commands

/opt/cpanel/ea-php70/root/usr/bin/php bin/magento cache:clean
/opt/cpanel/ea-php70/root/usr/bin/php bin/magento cache:flush

i got the following

Warning: Uncaught Exception: Warning: require(/home/btcegyptgold/public_html/setup/config/application.config.php): failed to open stream: No such file or directory in /home/btcegyptgold/public_html/vendor/magento/framework/Console/Cli.php on line 57 in /home/btcegyptgold/public_html/vendor/magento/framework/App/ErrorHandler.php:61 Stack trace:

0 /home/btcegyptgold/public_html/vendor/magento/framework/Console/Cli.php(57): Magento\Framework\App\ErrorHandler->handler(2, 'require(/home/b...', '/home/btcegyptg...', 57, Array)

1 /home/btcegyptgold/public_html/vendor/magento/framework/Console/Cli.php(57): require()

2 /home/btcegyptgold/public_html/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')

3 {main} thrown in /home/btcegyptgold/public_html/vendor/magento/framework/App/ErrorHandler.php on line 61

Ghulam.M
9738 silver badges25 bronze badges
asked Oct 30, 2018 at 11:03
4
  • just make sure in app/etc/env.php host, dbname, username and password's values are correct as per your new database server, Also try once in private window Commented Oct 30, 2018 at 11:07
  • When do the error displays ? On frontend or admin ? Commented Oct 30, 2018 at 11:17
  • it's in front, and database connection is corretct Commented Oct 30, 2018 at 11:17
  • Also note that the error displayed the old user connection not the one in file Commented Oct 30, 2018 at 11:18

3 Answers 3

0

Run this and see if it works :

find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
chmod u+x bin/magento
answered Oct 30, 2018 at 11:20
1
  • I did but it's still not working Commented Oct 30, 2018 at 11:28
0

I faced the same issue in past, cache flush works for me

login your server via ssh

and fire below command

cd /YourMagentoPath
php bin/magento cache:flush
answered Oct 30, 2018 at 13:57
1
  • I got the same error above Commented Oct 30, 2018 at 15:07
0

Make sure you have changed the credentials in app/etc/env.php.

Find this part and double check it:

 'db' => 
 array (
 'table_prefix' => '',
 'connection' => 
 array (
 'default' => 
 array (
 'host' => '[host]',
 'dbname' => '[dbname]',
 'username' => '[user]',
 'password' => '[password]',
 'active' => '1',
 ),
 ),
 ),

After, make sure you flush your cache! Also, if you are using Redis or Memcached, flush cache for those too.


If you are sure all the above is correct, the most probable issue will be that the database user have not enough "User Privileges" for the given database.


In regards to the new error you are getting, try to manually remove following:

var/generation
var/cache
var/view_preprocessed
var/page_cache
var/di

Also, try to give bin/magetno correct permissions:

chmod u+x bin/magento
answered Oct 30, 2018 at 11:53
5
  • Note: the error and connection not the same user Commented Oct 30, 2018 at 11:58
  • Are you using redis or memcached? If so, remove the cache! Commented Oct 30, 2018 at 12:01
  • See my updated answer. Commented Oct 30, 2018 at 12:52
  • i already did before adding my post, but i don't have "var/di" Commented Oct 30, 2018 at 13:04
  • Try this? :P Updated the answer Commented Oct 30, 2018 at 14:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.