<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://thebestlinux.com/index.php?action=history&amp;feed=atom&amp;title=MySQL_Backup_Restore</id>
	<title>MySQL Backup Restore - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://thebestlinux.com/index.php?action=history&amp;feed=atom&amp;title=MySQL_Backup_Restore"/>
	<link rel="alternate" type="text/html" href="https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;action=history"/>
	<updated>2026-05-01T17:43:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.7</generator>
	<entry>
		<id>https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=1261&amp;oldid=prev</id>
		<title>Jamie at 10:48, 4 March 2023</title>
		<link rel="alternate" type="text/html" href="https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=1261&amp;oldid=prev"/>
		<updated>2023-03-04T10:48:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;amp;diff=1261&amp;amp;oldid=300&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Jamie</name></author>
	</entry>
	<entry>
		<id>https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=300&amp;oldid=prev</id>
		<title>Jamie at 22:13, 17 August 2012</title>
		<link rel="alternate" type="text/html" href="https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=300&amp;oldid=prev"/>
		<updated>2012-08-17T22:13:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:13, 17 August 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MySQL: Exporting, Backup and Restore from the Linux command line&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MySQL: Exporting, Backup and Restore from the Linux command line&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jamie</name></author>
	</entry>
	<entry>
		<id>https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=299&amp;oldid=prev</id>
		<title>Jamie at 22:12, 17 August 2012</title>
		<link rel="alternate" type="text/html" href="https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=299&amp;oldid=prev"/>
		<updated>2012-08-17T22:12:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:12, 17 August 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MySQL: Exporting, Backup and Restore&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MySQL: Exporting, Backup and Restore &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;from the Linux command line&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jamie</name></author>
	</entry>
	<entry>
		<id>https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=286&amp;oldid=prev</id>
		<title>Jamie: Created page with &quot;MySQL: Exporting, Backup and Restore  This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments. E...&quot;</title>
		<link rel="alternate" type="text/html" href="https://thebestlinux.com/index.php?title=MySQL_Backup_Restore&amp;diff=286&amp;oldid=prev"/>
		<updated>2012-02-03T04:38:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;MySQL: Exporting, Backup and Restore  This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments. E...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;MySQL: Exporting, Backup and Restore&lt;br /&gt;
&lt;br /&gt;
This note briefly covers how to export a database out of MySQL and back in. This is useful for moving databases between test environments.&lt;br /&gt;
Exporting a Database&lt;br /&gt;
&lt;br /&gt;
To export a database, use the mysqldump utility normally located in your mysql/bin directory . For example, to export all the tables and data for a database named guestdb:&lt;br /&gt;
&lt;br /&gt;
mysqldump guestdb &amp;gt; guestdb.txt&lt;br /&gt;
&lt;br /&gt;
This will create a text file containing all the commands necessary to recreate all the tables and data found in guestdb. However, what if I want to export only one table? To do this the command is modified as follows assuming guestTbl is the table to be exported.:&lt;br /&gt;
&lt;br /&gt;
mysqldump guestdb guestTbl &amp;gt; guestdb.txt&lt;br /&gt;
&lt;br /&gt;
One important point. The data created in the txt file assumes that no table exists on your destination server. The --add-drop-table option adds code to drop a table if it exists in the new database when the file is imported. Also, not login is used in this example. In many cases, you need to log in. To be able to perform the command. So a complete example of the command line looks like this.&lt;br /&gt;
&lt;br /&gt;
mysqldump -p --user=username --add-drop-table guestdb guestTbl&lt;br /&gt;
Enter password: ********&lt;br /&gt;
&lt;br /&gt;
The -p option tells MySQL to prompt for a password. The --user option sets your username, and --add-drop-table adds the code necessary to drop a table if it exists during import. The output from the command looks like this:&lt;br /&gt;
&lt;br /&gt;
guestdb.txt&lt;br /&gt;
&lt;br /&gt;
# MySQL dump 8.11&lt;br /&gt;
#&lt;br /&gt;
# Host: localhost Database: guestdb&lt;br /&gt;
#--------------------------------------------------------&lt;br /&gt;
# Server version 3.23.28-gamma&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Table structure for table 'guestTbl'&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
DROP TABLE IF EXISTS guestTbl;&lt;br /&gt;
CREATE TABLE guestTbl (&lt;br /&gt;
msgID int(11) NOT NULL auto_increment,&lt;br /&gt;
name varchar(30),&lt;br /&gt;
email varchar(30),&lt;br /&gt;
msgFrom varchar(30),&lt;br /&gt;
msgDate timestamp(14),&lt;br /&gt;
msgBody text,&lt;br /&gt;
PRIMARY KEY (msgID)&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Dumping data for table 'guestTbl'&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
INSERT INTO guestTbl VALUES (1,'Test User1','testuser@test.com','Smallville USA'&lt;br /&gt;
,20010101182157,'This is teh body for message 1.');&lt;br /&gt;
INSERT INTO guestTbl VALUES (2,'Test User2','testuser2@test.com','Smallville USA&lt;br /&gt;
',20010101182352,'This is teh body for message 2.');&lt;br /&gt;
INSERT INTO guestTbl VALUES (3,'Test User3','testuser3@test.com','Smalltown USA'&lt;br /&gt;
,20010101182451,'This is teh body for message 3.');&lt;br /&gt;
INSERT INTO guestTbl VALUES (4,'Test User4','testuser4@test.com','Smallcity USA'&lt;br /&gt;
,20010101182519,'This is teh body for message 4.');&lt;br /&gt;
Importing the Database&lt;br /&gt;
&lt;br /&gt;
With the data in a text file, its time to import the data back into MySQL. This can be done by passing the commands contained in the text file into the MySQL client. For example:&lt;br /&gt;
&lt;br /&gt;
mysql -p --user=username &amp;lt; guestdb.txt&lt;br /&gt;
&lt;br /&gt;
This passes all the commands in the file into the mysql client just like you were typing them in.&lt;br /&gt;
&lt;br /&gt;
Note: While developing this tip, it was noted that the command created were missing a use statement. You made need to add a use database; statement to the text file to make the command work.&lt;br /&gt;
Backing Up and Restoring a MySQL Database&lt;br /&gt;
&lt;br /&gt;
To make a database backup using the MySQL command-line utilities, execute the following command:&lt;br /&gt;
&lt;br /&gt;
$ mysqldump -u username -p --opt dbname &amp;gt; dump.sql&lt;br /&gt;
&lt;br /&gt;
If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program:&lt;br /&gt;
&lt;br /&gt;
$ /usr/local/mysql/bin/mysqldump -u username -p --opt dbname &amp;gt; dump.sql&lt;br /&gt;
&lt;br /&gt;
Download the dump.sql and keep it in a safe place (CDR, Zip disk, etc).&lt;br /&gt;
&lt;br /&gt;
If you need to restore your database, you can do so like this:&lt;br /&gt;
&lt;br /&gt;
$ mysql -u username -p --database=dbname &amp;lt; dump.sql&lt;/div&gt;</summary>
		<author><name>Jamie</name></author>
	</entry>
</feed>