Magento 2 – How to Install with Empty Database Password

installmagento2

I'm trying to install Magento 2 on server which doesn't use database password. It's a kind of cloud hosting and I don't have ability to set password there.

Is there any way to install M2 using CLI with empty password?

I tried this installation command call:

cd bin/; /usr/bin/php ./magento setup:install \
        --currency=USD \
        --base-url=<URL> \
        --base-url-secure=<URL> \
        --language=en_US \
        --timezone=America/Los_Angeles \
        --db-host=<HOST> \
        --db-name=main \
        --db-user=user \
        --backend-frontname=admin \
        --admin-user=admin \
        --admin-firstname=John \
        --admin-lastname=Doe \
        --admin-email=john@example.com \
        --admin-password=admin12

And I got exception:

Configuration array must have a key for 'password' for login credentials  

Then I tried to provide empty password:

cd bin/; /usr/bin/php ./magento setup:install \
        --currency=USD \
        --base-url=<URL> \
        --base-url-secure=<URL> \
        --language=en_US \
        --timezone=America/Los_Angeles \
        --db-host=<HOST> \
        --db-name=main \
        --db-user=user \
        --db-password='' \
        --backend-frontname=admin \
        --admin-user=admin \
        --admin-firstname=John \
        --admin-lastname=Doe \
        --admin-email=john@example.com \
        --admin-password=admin12

But got another exception:

The "--db-password" option requires a value. 

Do you know if Magento 2 installation on database server which doesn't use password is supported?

It worked fine for me with Magento 1, I've just provided empty password there:

--db_pass '' \

Best Answer

The following works for me on Ubuntu:

./bin/magento setup:install \
    --db-host=localhost \
    --db-name=magento \
    --db-user=root \
    --backend-frontname=admin \
    --base-url=http://some.host/ \
    --language=en_US \
    --timezone=America/Chicago \
    --currency=USD \
    --admin-lastname=Admin \
    --admin-firstname=Admin \
    --admin-email=admin@example.com \
    --admin-user=admin \
    --admin-password=123123q \
    --cleanup-database \
    --use-rewrites=1

The problem may be that you are using remote MySQL host, not localhost. Not sure that it is possible to connect to remote MySQL host without password.

Related Topic