2

I have deployed Magento 2.1.2 CE and have setup the database to use with this instance.

# http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-install.html#instgde-install-cli-magento
php ${DIR_MAGE}/bin/magento setup:install  \
--admin-firstname="${ADMIN_FIRSTNAME}" \
--admin-lastname="${ADMIN_LASTNAME}" \
--admin-email="${ADMIN_EMAIL}" \
--admin-user="${ADMIN_USER}" \
--admin-password="${ADMIN_PASSWORD}" \
--base-url="${BASE_URL}" \
--backend-frontname="${BACKEND_FRONTNAME}" \
--language="${LANGUAGE}" \
--currency="${CURRENCY}" \
--timezone="${TIMEZONE}" \
--use-rewrites="${USE_REWRITES}" \
--use-secure="${USE_SECURE}" \
--use-secure-admin="${USE_SECURE_ADMIN}" \
--admin-use-security-key="${ADMI_USE_SECURITY_KEY}" \
--session-save="${SESSION_SAVE}" \
--cleanup-database \
--db-host="${DB_HOST}" \
--db-name="${DB_NAME}" \
--db-user="${DB_USER}" \
--db-password="${MAGE_DBPASS}" \

I want to re-deploy Magento instance and I want to use the same DB. I tried to run this command after re-deployment:

php ${DIR_MAGE}/bin/magento setup:config:set  \
--backend-frontname="${BACKEND_FRONTNAME}" \
--key="${SECURE_KEY}" \
--session-save="${SESSION_SAVE}" \
--db-host="${DB_HOST}" \
--db-name="${DB_NAME}" \
--db-user="${DB_USER}" \
--db-password="${MAGE_DBPASS}" \

this message is displayed:

We saved default values for these options: db-host, db-engine, db-prefix, db-model, db-init-statements.

but when I go to the front of my site I see that setup mode is started:

Magento 2 setup mode after re-deployment

How can I re-deploy Magento 2 CE and re-connect to existing DB?

1

If you have DB already, you can modify app/etc/env.php to connect the existing DB

Between line 16 and 29:

  'db' =>
  array (
    'table_prefix' => '${DB_PREFIX}',
    'connection' =>
    array (
      'default' =>
      array (
        'host' => '${DB_HOST}',
        'dbname' => '${DB_NAME}',
        'username' => '${DB_USER}',
        'password' => '${MAGE_DBPASS}',
        'active' => '1',
      ),
    ),
  ),
  • I have fresh empty Magento 2 instance after re-deployment, w/o app/etc/env.php & app/etc/config.php :( – Alex Gusev Dec 14 '16 at 8:10
  • Did the folder app/etc is set to 777? – PY Yick Dec 14 '16 at 8:19
  • 2
    Thanks, @py-yick, I found the solution - I need to use setup:install again w/o --cleanup-database option and with the same admin user parameters (first, last, email, username, password). – Alex Gusev Dec 14 '16 at 8:27
  • Good to see you solved your problems. Just wonder why app/etc/env.php is not included on the core file? – PY Yick Dec 15 '16 at 3:14
  • 1
    I suppose files app/etc/env.php and app/etc/config.php are generated by bin/magento in setup:install time. I have deployed M2 using composer. – Alex Gusev Dec 15 '16 at 6:59
1

To use an existing database open app/etc/env.php and update your database credential.

Then double check to make sure the 'install' array key exists.

... 
'install' => array (
     'date' => 'Mon, 28 Nov 2016 23:01:06 +0000',
 ),
 ...
0

Need to reinstall by doing the following steps:-

generated/* folder. It is also important to remove the app/etc/config.php and app/etc/env.php to do a fresh install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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