3

I have a mysql database with 10 tables and need to drop and repopulate the database to run some performance tests. Using mysqldump, I can dump out the data. What steps should I follow next, to clear the database, and re-import? Will need to run this for different sizes of the database (i.e. tables with different number of rows) to calculate the db performance, so I need to make sure these steps can be replicated.

1
  • mysqldump can include the full DDL, including drop statements to kill previous installs of a table. Commented Oct 31, 2012 at 15:15

3 Answers 3

4

You might want to look at the options on mysqldump such as --add-drop-database and --add-drop-table. I'd probably go for --add-drop-database in this case.

Sign up to request clarification or add additional context in comments.

1 Comment

Just for interests sake, would you have to re-grant user permissions if using --add-drop-database ?
1

1) take the dump

    drop database db_name
    create database db_name
    mysql -u user -p db_name < dump.sql

I am sure this can be repeated any number of times. Its idempotent

Comments

1

From the MySQL console:

mysql> DROP DATABASE [dbName]; 
mysql> CREATE DATABASE [dbName];
mysql> USE [dbName];
mysql> SOURCE [pathToSQLDump];

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.