I tried everything as suggested but the issue still remains, after that I remove/disabled all the third-party modules and tried again and now it worked fine, after installation, I enable/install modules again.
hope this might help someone.
I'm probably late to the party, but I've managed to deal with this issue by running the following command.
php bin/magento setup:uninstall
This will remove any existing config files including env.php from the previous installation, properly uninstalling Magento and this will allow you to go through the installation process without issues.
I assume this ...