How to create a database in the terminal – MySQL – Ubuntu 14.04
The first thing we are going to do is to log into the MySQL root shell, you will be prompted for your MySQL root password. (remember to change the text there is red to whatever you want the database,user and password to be)
# mysql -u root -p
You should have access to MySQL and you want to run this command to create your database.
# CREATE DATABASE databasename;
MySQL statement must end in a semi-colon ; so make sure to check this is present if you are running into any issues.
Now we want to create you database user and set a password for that user by entering the following command
# CREATE USER databaseuser@localhost IDENTIFIED BY 'databasepassword';
At this point we have a database and a database user, these two components does not yet have any relationship with each other. But lets make an end to that by running this :
# GRANT ALL PRIVILEGES ON database.* TO databasesuser@localhost;
so now we have connected the two components and we want to flush the privileges so MySQL can see the new user and database
# FLUSH PRIVILEGES;
At this point you should have created and combined the database and user and should be ready to use. Exit the Mysql Shell with