Difference between revisions of "Backup MySQL"

From GWAVA Technologies Training
Jump to: navigation, search
Line 11: Line 11:
 
====Linux====
 
====Linux====
 
At the command line type  
 
At the command line type  
 +
 +
<pre style="white-space: pre-wrap;
 +
white-space: -moz-pre-wrap;
 +
white-space: -pre-wrap;
 +
white-space: -o-pre-wrap;
 +
word-wrap: break-word;">
  
 
Server:/ # mysqldump --single-transaction --quick retain > retain.date.sql -u root -p
 
Server:/ # mysqldump --single-transaction --quick retain > retain.date.sql -u root -p
 +
 +
</pre>
  
 
Explanation of the command:
 
Explanation of the command:
  
mysqldump The command to get started telling MySQL you want to make a dump file
+
'''<span style=color:#800000>mysqldump:</span>''' The command to get started telling MySQL you want to make a dump file
 +
 
 +
'''<span style=color:#800000>--single-transaction and --quick:</span>''' switches you want to apply, [http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html read up on it in the documentation mentioned above if you'd like to fiddle with it some more.]  There's a lot you can tweak.
 +
 
 +
'''<span style=color:#800000>retain:</span>''' This part is the database you want to export/dump.  Whatever you named your Retain database this is what you'll call it.  If you have a separate database for your configuration remember to export that too.
  
--single-transaction and --quick: switches you want to apply, [http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html read up on it in the documentation mentioned above if you'd like to fiddle with it some more.] There's a lot you can tweak.
+
'''<span style=color:#800000>>:</span>'''  This is the "export to" pointer, I.E. direction you're pushing the dataIn theory you could reverse them and put the location firs and then the name of the database, but the above example for sure works.
  
retain: This part is the database you want to export/dump
+
'''<span style=color:#800000>retain.date.sql:</span>''' This is the name of the file you'll be creating with the mysqldump command.  You have the power to name it whatever you like.  Like cheesepuffs.txt or OutOfGum.rip.  You can also tell it to place the file in a specific location, so /mysqldump/file.sql You can put whatever extension you want on it, recommended you put .sql on the end so that you don't have to think what kind of file it is.  As far as "best practices" go: RetainDatabase.Date.sql would probably make the most sense, substituting "Date" for the day you created the dump file.
  
>(export to pointer, I.E. direction you're pushing the data) retain.date.sql (this can be  
+
The rest is logging into MySQL the way you would any other time. Root makes sure that you won't have any permissions issues, but it can be done with the same user that has full rights to the database.
  
 
====Windows====
 
====Windows====

Revision as of 21:11, 9 January 2015

This article is a very bare bones "dummy's guide" set of information. If you'd like to learn more check out the MySQL page on using MySQL dump: http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html Or this article on database backup methods if you'd like to look into other options. Plus there's a whole world of internet to search.

Contents

 [hide

MySQL dump

The mysqldump program bundled with MySQL is one of the best ways that has been found to backup a MySQL database.

For Retain you'll want to use the --single-transaction and possibly the --quick switch Check out the MySQL documentation on those switches here.

Using the --quick switch may depend on the size of your database, the bigger it is the more important it may become to use it for your dump script.

Examples

Linux

At the command line type

Server:/ # mysqldump --single-transaction --quick retain > retain.date.sql -u root -p

Explanation of the command:

mysqldump: The command to get started telling MySQL you want to make a dump file

--single-transaction and --quick: switches you want to apply, read up on it in the documentation mentioned above if you'd like to fiddle with it some more. There's a lot you can tweak.

retain: This part is the database you want to export/dump. Whatever you named your Retain database this is what you'll call it. If you have a separate database for your configuration remember to export that too.

>: This is the "export to" pointer, I.E. direction you're pushing the data. In theory you could reverse them and put the location firs and then the name of the database, but the above example for sure works.

retain.date.sql: This is the name of the file you'll be creating with the mysqldump command. You have the power to name it whatever you like. Like cheesepuffs.txt or OutOfGum.rip. You can also tell it to place the file in a specific location, so /mysqldump/file.sql You can put whatever extension you want on it, recommended you put .sql on the end so that you don't have to think what kind of file it is. As far as "best practices" go: RetainDatabase.Date.sql would probably make the most sense, substituting "Date" for the day you created the dump file.

The rest is logging into MySQL the way you would any other time. Root makes sure that you won't have any permissions issues, but it can be done with the same user that has full rights to the database.

Windows

Personal tools
Namespaces

Variants
Actions
Home
Exchange
GroupWise
JAVA
Linux
MTK
Retain
GW Monitoring and Reporting (Redline)
GW Disaster Recovery (Reload)
GW Forensics (Reveal)
GWAVA
Secure Messaging Gateway
GW Mailbox Management (Vertigo)
Windows
Other
User Experience
Toolbox
Languages
Toolbox