Solved

restore mysql server question

Posted on 2014-01-16
3
279 Views
Last Modified: 2014-01-16
Hello,
  I have a database already created. Now, I would like to restore a backup copy. Does the commands MySQL -<id> -p <database> < backup.sql delete the existing database and then create a new one or do I have to do the following

1: delete the existing DB
2: Create the database
2: restore the backup

Thanks for your help
0
Comment
Question by:SiemensSEN
3 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 200 total points
ID: 39786099
Whenever I have done this, the database (schema) remains because the first line of the backup SQL file usually is as follows.
CREATE DATABASE  IF NOT EXISTS `db_name`;
USE `db_name`;

Open in new window


If you want to create a new database, you can change the top two lines of the code.  If I remember correctly, you can remove them and in the Workbench the new schema option will work.  Otherwise, it ignores that because of the USE schema name statement.
0
 

Author Closing Comment

by:SiemensSEN
ID: 39786205
Thanks
0
 
LVL 8

Expert Comment

by:Surrano
ID: 39786693
It depends on your database dump file. E.g. using mysqldump, it is possible to request a "drop database" in the dump, using --add-drop-database
So have a look at the beginning of your backup.sql and if you can see something like "drop database ..." then you don't have to explicitly drop it.

As for creation, there's a similar option --no-create-db; unless invoked this way the "create database" will be present in the dump. Look for it.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

20 Experts available now in Live!

Get 1:1 Help Now