Solved

restore mysql server question

Posted on 2014-01-16
3
285 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Creating and Managing Databases with phpMyAdmin in cPanel.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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