Login in mysql using:
$ mysql -u root -p
First create a database using:
mysql> create database dbname;
Query OK, 1 row affected (0.00 sec)
Then in mysql shell create new user using:
mysql> create user 'username'@'localhost' IDENTiFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on dbname.* to 'username'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)
Or you can use ‘%’ wildcard if you want to connect mysql from any host:
mysql> create user 'username'@'%' IDENTiFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on dbname.* to 'username'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
For more details visit mysql manual.