Magento 2.1 : CLI install command failed
If you are trying to install it over the same installation please try to uninstall it first. As seen on magento official docs:
/magento_root/bin/magento setup:uninstall
Then run your command again.
If this fails again then drop your database and re-run your commands as @Amit Bera already said.
Deleting /app/etc/env.php
fixes the problem. It will be regenerated by the bin/magento setup:install
command.
I found out the reason of this error. Some extensions add custom CLI commands. Check di.xml for:
Magento\Framework\Console\CommandListInterface
Magento\Framework\Console\CommandList
The problem is these commands include classes that require data in tables. But you didn't install the system. For example, if you try to include Magento\Framework\Stdlib\DateTime\TimezoneInterface in your command class you will get error like:
Base table or view not found: 1146 Table 'magento.store_website' doesn't exist, query was: SELECT `store_website`.* FROM `store_website` - skipping database cleanup
Try to remove custom extensions before an installation.
P.S. Tested on Magento 2.3.1.