These are the basic steps to easily create a database and assign a user to it from the command line in Linux or Windows:


1. Login into Command Line Interface:

mysql -u root -p
Enter password:

2. Create database:

CREATE DATABASE my_database;

3. Create user:

CREATE USER 'database_user'@'localhost' IDENTIFIED BY 'user_password';

4. Allow our user to connect to localhost:

GRANT USAGE on *.* to database_user@localhost identified by 'user_password';

5. Grant privileges to our user:

GRANT ALL PRIVILEGES on my_database.* to database_user@localhost ;

6. Flush privileges, just in case:



That's about it :)