Create MySQL Database

Create MySQL Database

Connect to the MySQL server from the command line as root:

mysql -u root -p

Create MySQL Database

Use the following syntax to create a database in MySQL:

CREATE DATABASE name_base;

Create a new user:

GRANT ALL PRIVILEGES ON name_base.* TO name_user@localhost IDENTIFIED BY 'PASSWORD';

If MySQL version  is 8 or lower:

We create the base:

CREATE DATABASE db_name;

Create a user:

CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'pAsWoRd';

Adding a user to the database:

GRANT ALL PRIVILEGES ON db_name.* TO 'user_name'@'localhost';