HowTo : Create MySQL Database from the Command Line
Creating MySQL Database from the command line is quite a common task.
We'll create database named
User will have all privileges on this database and will be allowed to connect only from the
Step 1 : Log into MySQL shell as root.
$ mysql -u root -p
Step 2 : Create a database
mysql> CREATE DATABASE test_db;
Step 3 : Add a user named
mysql> GRANT ALL PRIVILEGES ON test_db.* TO john@localhost IDENTIFIED BY 'pass';
Now you can log into MySQL server as
$ mysql -u john -p
Execute the following command to list databases :
mysql> SHOW DATABASES;