How to install Strapi v4 with MySQL 8 (part 2)

Preparing Mysql things:

1. Add MySQL to $PATH variable to be sure that you can use it from command line:

echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile

(In my case, I add MySQL to .zshrc file)

2. log into MySQL has root

mysql --user=root -p

3. Create a new database user:

CREATE USER ‘strapi’@‘localhost’ IDENTIFIED WITH mysql_native_password BY '123456';

Note: WITH mysql_native_password is very important, because Strapi don’t allow the most recent MySQL authentication “caching sha2 password”.

And then provide the user with access to the information they will need:

GRANT ALL PRIVILEGES ON * . * TO 'strapi'@'localhost';
CREATE USER ‘strapi’@‘localhost’ IDENTIFIED WITH mysql_native_password BY 'ambrosoli';

Reload all the privileges:

FLUSH PRIVILEGES;

4. Log in as the new database user you just created:

mysql -u strapi -p

5. Create a new database:

CREATE DATABASE strapi;

6. Finally, quit mysql command line using quit;.

Install Strapi

1. Select de right node version: (this is very important!)

nvm use 14

2. create a new Strapi project:

npx create-strapi-app@latest strapi 

3. Select a custom installation, needed to config MySQL:

Create a new custom Strapi project

4. Select MySQL database:

Select mysql database

5. Set the MySQL parameters (you are going to use the user and database created above):

Set the MySQL parameters

Don’t worry, you can change this later at config/database.js file, inside Strapi project.

6. Finally, run the following code at the commnand line:

npm run develop

If everything gets right, you should see the following page:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store