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
-
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 windowHitesh– Hitesh2018年10月30日 11:07:20 +00:00Commented Oct 30, 2018 at 11:07
-
When do the error displays ? On frontend or admin ?Ylgen Guxholli– Ylgen Guxholli2018年10月30日 11:17:04 +00:00Commented Oct 30, 2018 at 11:17
-
it's in front, and database connection is corretctHala Atef– Hala Atef2018年10月30日 11:17:36 +00:00Commented Oct 30, 2018 at 11:17
-
Also note that the error displayed the old user connection not the one in fileHala Atef– Hala Atef2018年10月30日 11:18:11 +00:00Commented 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 workingHala Atef– Hala Atef2018年10月30日 11:28:57 +00:00Commented 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 aboveHala Atef– Hala Atef2018年10月30日 15:07:37 +00:00Commented 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:
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
-
Note: the error and connection not the same userHala Atef– Hala Atef2018年10月30日 11:58:00 +00:00Commented Oct 30, 2018 at 11:58
-
Are you using redis or memcached? If so, remove the cache!Greg– Greg2018年10月30日 12:01:02 +00:00Commented Oct 30, 2018 at 12:01
-
-
i already did before adding my post, but i don't have "var/di"Hala Atef– Hala Atef2018年10月30日 13:04:04 +00:00Commented Oct 30, 2018 at 13:04
-
Try this? :P Updated the answerGreg– Greg2018年10月30日 14:10:28 +00:00Commented Oct 30, 2018 at 14:10