Knowledge Base

January 8, 2008

How to create database using mysql commands

Filed under: Technical — Tags: — rkutti @ 9:39 am

To create database from command prompt. Login to mysql as root user.
To login into mysql prompt in linux machine.
Type the following command in the console

$ mysql -u <username> -p<password>

After entering the mysql prompt follow these steps to create a database
and load the database with sql file.

A CREATE DATABASE statement to create a database.
> create database <databasename>;

A GRANT statement to grant privileges to database.
> grant all on <databasename>.* to <username>@localhost identified by ‘<password>’;

A FLUSH PRIVILEGES statement to tell the server to reload the grant.
> flush privileges;

A USE statement to tell the server to use the given database for further operations.
> use <databasename>;

A SOURCE statement to tell server to load the given sql file in the database.
> source <filename.sql>

2 Comments »

  1. Gud info :) Keep going.

    Comment by svidhya — January 8, 2008 @ 9:43 am

  2. grant all on
    Here all means ALL the privileges.
    You can specify the particular privileges like Select …

    Comment by Sanjay — January 10, 2008 @ 11:48 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.