Import  MySQL database  Newbir Question

Posted on 2011-04-25
Last Modified: 2012-05-11
Good day,

I run a mysql server on Linux.

I have a mysql database dumpfile on a  prodserver . I would like to create a NEW DB on the same server and import this backup into it..  

I have logged in, and created a database like this:

Mysql> create database testmax;
Query OK, 1 row affected (0.06 sec)
mysql> use testmax;
Database changed
mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| phpmyadmin         |
| procorp            |
| testmax            |

(I want to import  procorp's backup in testmax)

Now, I am at the part where i want  to populate this testmax  database with my existing  procorp backup. I also want to make sure i dont overwrite the procorp database (production database)

How do I do that?

I know in Oracle you can set ORACLE_SID but im not familiar with mysql.
Question by:maxalarie
    LVL 24

    Accepted Solution

    Export procorp using mysqldump

    mysqldump -u user -p procorp > dumpfilename

    Import it using mysql

    mysql -u user -p testmax < dumpfilename

    LVL 1

    Assisted Solution

    You first need to create a dump/backup file of current database

    mysqldump --routines -p <username> -p <password> procorp > dump.sql

    --routines flag will instruct mysqldump to also dump triggers and functions

    then login to mysql commandline tool

    mysql -u <username> -p<password>

    then type following 2 commands

    use testmax;

    source <pathtodumpfile>;

    LVL 2

    Author Closing Comment

    Thanks guys,.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Creating and Managing Databases with phpMyAdmin in cPanel.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now