9

I downloaded magento 2-2.4.1.zip. Unzipped it to /var/www/html/magento24/ - my local folder for local domain http://magento24.local configured by nginx on ubuntu20.04.

I had done composer update or install and next use this command:

bin/magento setup:install --base-url=http://magento24.local \
 --db-host=localhost --db-name=magento24 --db-user=user24 --db-password=1234 \
 --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
 --admin-user=admin --admin-password=test1234 --language=en_US \
 --currency=USD --timezone=America/Chicago --use-rewrites=1

This stopped on step 4:

[Progress: 4 / 818]
Installing database schema:

In WebsiteRepository.php line 159:
                                                                     
  The default website isn't defined. Set the website and try again.  

I tried different way. To download magento2.4.1 by composer from magento repository:

php /bin/composer1/composer.phar create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.1 .

But this first throw problems with composer version (first i use coimposer 2.0.x, next uses 1.0.0alpha - different errors php7.3 and php7.1 fpm)

1

5 Answers 5

33

It appears that this error might appear when a MySQL database is empty, but the env.php file is present. (Possibly because you had setup Magento, but for some reason, database was deleted.)

To fix this you can add --cleanup-database flag to setup:install command (For me, it went ok only after the second try.), or delete the env.php file indeed, which I don't recommend.

10

I was changing a db and removing env.php helped to get rid of the error for me.

1
  • Thank you, deleting the previous app/etc/env.php fixed the problem
    – snez
    Feb 26, 2021 at 10:57
4

=>>> DELETE env.php file ..its work

After run this command

php bin/magento setup:install --base-url="http://localhost/magento4" --db-host="localhost" --db-name="magento4" --db-user="root" --db-password= --admin-user="admin" --admin-password="admin@123" --admin-firstname="admin12" --admin-lastname="user" --admin-email="admin12@example.com" --backend-frontname="admin"

2

I finally managed to to work this:

Use composer version 1.9.0:

1. Instal composer 1.9. Or You can downgrade it.

  • cd /var/www/html/mag241/

  • php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

  • sudo php composer-setup.php --install-dir=/bin/composer19 --version=1.9.0

2. Use composer 1.9 to get magento2.4.1.

  • php /bin/composer19/composer.phar create-project
    --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.1 .

3. Run bin/magento setup:install with Your database adres login and url

  • php bin/magento setup:install --base-url=http://magento24.local/
    --db-host=localhost --db-name=magento24 --db-user=user24 --db-password=1234 --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=es-host.example.com --elasticsearch-port=9200
0

It occurs if default website's data is not found which is stored in [store_website]. That means Magento site can't connect to database or database tables. For my case, I installed Magento with "m_" prefix for tables, then I changed its database whose tables doesn't have any prefix. So, to fix this issue, I modified:

'table_prefix' => 'm_' to 'table_prefix' => '' in app/etc/env.php

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.