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


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

  • 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
    – Hitesh
    Oct 30, 2018 at 11:07
  • When do the error displays ? On frontend or admin ? Oct 30, 2018 at 11:17
  • it's in front, and database connection is corretct
    – Hala Atef
    Oct 30, 2018 at 11:17
  • Also note that the error displayed the old user connection not the one in file
    – Hala Atef
    Oct 30, 2018 at 11:18

3 Answers 3


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
  • I did but it's still not working
    – Hala Atef
    Oct 30, 2018 at 11:28

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
  • I got the same error above
    – Hala Atef
    Oct 30, 2018 at 15:07

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:


Also, try to give bin/magetno correct permissions:

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.