So with a fresh new Magento 2 instance successfully downloaded and sitting happily in a directory, you can choose to either install through the setup Wizard, which is browser based, or you can choose to install via the command line.
Perhaps a hangover from many years passed, but I rarely trust browser based installers. All too often they would fail after creating half the DB forcing you to scrub it and start again, or suddenly decide they need another extension x, y or z. So I always go the CLI route where possible.
So if you go into the root of your lovely fresh, brand new Magento 2 code base, open a terminal window, and run the following – once you’ve replaced the values in bold with your actual values.
php bin/magento setup:install –base-url=”https://m2.app/” –db-host=”localhost” –db-name=”m2” –db-user=”m2-user” –db-password=”this-is-honestly-my-real-password” –admin-firstname=”Matt” –admin-lastname=”Rhys-Davies” –admin-email=”email@example.com” –admin-user=”Matt” –admin-password=”Another-Real-Password” –language=”en_GB” –currency=”GBP” –timezone=”Europe/London” –use-rewrites=”1” –backend-frontname=”admin“
Then hit the value in base-url and you will find – as if by magic – you are up and running with a brand spanking Magento 2 instance. Unless you’re running on Windows, in which case you will likely spend the next 4 hours debugging and wondering why, when it does work, it runs absurdly slowly.
Rinse and repeat for months until you finally cave in, buy a Mac and run Valet.
Even then, you may need to run the following command in order to allow you to connect to install. Seems like it doesn’t allow non-password access to database.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password