Solved

MySQL Dump & Restore

Posted on 2014-02-14
3
324 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

867 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