Solved

MySQL Dump & Restore

Posted on 2014-02-14
3
320 Views
Last Modified: 2014-02-15
Hi Experts,

I am trying to do a dump of all databases with:

C:\MySQL_DUMP>mysqldump --opt  --all-databases > c:\mysql_dump\all_dbs.sql -u root -p 123

Open in new window


However, my all_dbs.sql file simply contains the following contents, which I know is incorrect:

Usage: mysqldump [OPTIONS] database [tables]
 OR    mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
 OR    mysqldump [OPTIONS] --all-databases [OPTIONS]
 For more options, use mysqldump --help

Open in new window


I know I should expect over 100 lines with CREATE and INSERT statements.

As well, afterwards, how would I import?

The reason that I need to do this is because I need to reformat my system.

Thank you
0
Comment
Question by:APD_Toronto
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Andrej Pirman earned 500 total points
ID: 39860208
This should do for getting a dump into a single file PER DATABASE:

c:\MySQL\bin\mysqldump -u root -pPASSWORD -r backup.sql -q -x -f -F -e -B --add-drop-table --add-drop-database dbName

Note:
There IS space after -u parameter, and there is NOT any space after -p parameter!
Replace paths, username root, PASSWORD and dbName with your real data.

And this should import it back, again single database:

mysql --port=3306 -u root -pPASSWORD dbName < backup.sql


**EDIT**
sorry, did not read your question well.
You have syntax error in your line; you directed the output into, literally, file named "c:\mysql_dump\all_dbs.sql -u root -p 123". Also after -p there should be no space:
C:\MySQL_DUMP>mysqldump --opt  --all-databases > c:\mysql_dump\all_dbs.sql -u root -p 123

Open in new window

Should be:
C:\MySQL_DUMP>mysqldump --opt  --all-databases -r c:\mysql_dump\all_dbs.sql -u root -p123

Open in new window

0
 

Author Comment

by:APD_Toronto
ID: 39860699
OK, your code worked:

C:\MySQL_DUMP>mysqldump --opt  --all-databases -r c:\mysql_dump\all_dbs.sql -u root -p123

Open in new window


now, how do I import all databases?
0
 

Author Closing Comment

by:APD_Toronto
ID: 39862055
Thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
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…

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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now