Creating a new Database from a mysql dump file

16 / Apr / 2009 by gaurav 1 comments

In this use case we are using the jamesDump.sql stored at /home/gaurav/Desktop/jamesDump.sql file to create a new database named intelligrape.

First of all we need to login to the mysql prompt.

gaurav@gaurav:~$ mysql -u root -p
Enter Password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql > 

Here we need to create a new database named intelligrape which will replicate the old database

mysql >  create database intelligrape;
Query OK, 1 row affected (0.02 sec)

mysql >  use intelligrape;    //set intelligrape database as the current database in use
Database changed

mysql > source ~/Desktop/jamesDump.sql    //source command will read the script and copy the schema as well as the values from dumpfile into the database.
Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql > show tables    //it will show the list of all tables of intelligrape database created by dumpfile.

Hope it helps.

Gaurav Chauhan
gaurav@intelligrape.com

http://www.IntelliGrape.com/

FOUND THIS USEFUL? SHARE IT

comments (1 “Creating a new Database from a mysql dump file”)

  1. Sonu

    Hi,
    I have some basic question related to database in Grails. I have created a mysql database and filled with lots of data on XAMPP server. Now I want to put in grails environment. So How to do this?
    One thing more I want to ask..All the relation which I have made between tables in my database.. Will it be remain same when it will come to Grails and what about the Domain? Will it automatically created by Grails?

    Your blog is really interesting & useful.

    Many Thanks
    Sonu

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *