?
Solved

restore mysql server question

Posted on 2014-01-16
3
Medium Priority
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 800 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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