<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://knowledgenerd.net/index.php?action=history&amp;feed=atom&amp;title=Mysqldump</id>
	<title>Mysqldump - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://knowledgenerd.net/index.php?action=history&amp;feed=atom&amp;title=Mysqldump"/>
	<link rel="alternate" type="text/html" href="https://knowledgenerd.net/index.php?title=Mysqldump&amp;action=history"/>
	<updated>2026-10-30T15:23:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://knowledgenerd.net/index.php?title=Mysqldump&amp;diff=19&amp;oldid=prev</id>
		<title>Creator: Created page with &quot;Note! By default mysqldump uses &lt;code&gt;--lock-tables&lt;/code&gt; parameter when making a backup. That possibly prevents your website from working. * You may want to use &lt;code&gt;--skip...&quot;</title>
		<link rel="alternate" type="text/html" href="https://knowledgenerd.net/index.php?title=Mysqldump&amp;diff=19&amp;oldid=prev"/>
		<updated>2019-09-08T14:38:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Note! By default mysqldump uses &amp;lt;code&amp;gt;--lock-tables&amp;lt;/code&amp;gt; parameter when making a backup. That possibly prevents your website from working. * You may want to use &amp;lt;code&amp;gt;--skip...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Note! By default mysqldump uses &amp;lt;code&amp;gt;--lock-tables&amp;lt;/code&amp;gt; parameter when making a backup. That possibly prevents your website from working.&lt;br /&gt;
* You may want to use &amp;lt;code&amp;gt;--skip-lock-tables&amp;lt;/code&amp;gt; but that may cause inconsistency in the backup.&lt;br /&gt;
* You can also change all tables from MyISAM to InnoDB and use hotcopy or option &amp;lt;code&amp;gt;--single-transaction&amp;lt;/code&amp;gt;??? (haven't tested)&lt;br /&gt;
* If you are doing a backup on the server and your tables all are MyISAM tables, consider using the [http://dev.mysql.com/doc/refman/5.0/en/mysqlhotcopy.html mysqlhotcopy] instead because it can accomplish faster backups and faster restores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Backup Whole Database ==&lt;br /&gt;
&lt;br /&gt;
Connect to the database server e.g. using SSH connection and execute following row:&lt;br /&gt;
 mysqldump -u root -p drupal6 &amp;gt; drupal6_db_bu_20100625.sql&lt;br /&gt;
&lt;br /&gt;
You can also ask mysqldump to add a drop table command before every create command by using the option --add-drop-table (this is probably the default option already). This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.&lt;br /&gt;
&lt;br /&gt;
 mysqldump --add-drop-table -u root -p drupal6 &amp;gt; drupal6_db_bu_20100625.sql&lt;br /&gt;
 or&lt;br /&gt;
 mysqldump --add-drop-table -p drupal6 --user=root &amp;gt; /root/Desktop/drupal6_20100912.sql&lt;br /&gt;
&lt;br /&gt;
== Backup And Compress Database ==&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -p drupal6 | gzip &amp;gt; drupal6_db_bu_20100625.sql.gz&lt;br /&gt;
&lt;br /&gt;
== Backup Only Specified Tables ==&lt;br /&gt;
&lt;br /&gt;
Backup only &amp;quot;users&amp;quot; and &amp;quot;system&amp;quot; tables from the &amp;quot;drupal6&amp;quot; database:&lt;br /&gt;
&lt;br /&gt;
 mysqldump -u root -p drupal6 users system &amp;gt; drupal6_db_2_tables_bu_20100625.sql&lt;br /&gt;
&lt;br /&gt;
Useful command to check what tables exists in specified database:&lt;br /&gt;
 mysql -u root -p -e 'USE Drupal7; SHOW TABLES;'&lt;br /&gt;
&lt;br /&gt;
Backup and choose tables from text file. Tables have to be on the same line and separated by spaces:&lt;br /&gt;
 mysqldump -u root -p drupal6 `cat phpbb_tables_onsamerow.txt` &amp;gt; phpbb-tables-bu-20111019.sql&lt;br /&gt;
&lt;br /&gt;
=== Case: Backup All PhpBB Forum Tables ===&lt;br /&gt;
&lt;br /&gt;
* Get phpbbforum tables:&lt;br /&gt;
 mysql -u admin -p -h 123.23.1.1 -e 'USE drupal6; SHOW TABLES;' | grep 'phpbb_' &amp;gt; phpbb-tables.txt&lt;br /&gt;
&lt;br /&gt;
* Convert line breaks into spaces in phpbb-tables.txt file&lt;br /&gt;
 echo $(cat phpbb-tables.txt) &amp;gt; phpbb-tables-samerow.txt&lt;br /&gt;
&lt;br /&gt;
* Copy/backup table structure and data from source db:&lt;br /&gt;
 mysqldump -u admin -p -h 123.23.1.1 drupal6 `cat phpbb-tables-samerow.txt` &amp;gt; phpbb-tables-bu-20111020.sql&lt;br /&gt;
&lt;br /&gt;
* Restore data into a target database:&lt;br /&gt;
 mysql -u admin -p -h 123.23.1.1 drupal7 &amp;lt; phpbb-tables-bu-20111020.sql&lt;br /&gt;
&lt;br /&gt;
*Follow the progress:&lt;br /&gt;
 SHOW TABLE STATUS LIKE 'phpbb_%'&lt;br /&gt;
&lt;br /&gt;
== Backup a Remote Database ==&lt;br /&gt;
&lt;br /&gt;
 mysqldump -h xxx.xxx.xxx.xxx -u username -p database_name &amp;gt; backup_file_name_20100628.sql&lt;br /&gt;
&lt;br /&gt;
Use gzip to compress the remote database backup&lt;br /&gt;
 mysqldump -h xxx.xxx.xxx.xxx -u username -p database_name | gzip &amp;gt; backup_file_name_20100628.sql.gz&lt;br /&gt;
&lt;br /&gt;
'''Note!''' If you get for example following error message: &amp;lt;code&amp;gt;mysqldump: Got error: 1130: Host 'xxx.xx.xxx.x' is not allowed to connect to this MySQL server when trying to connect&amp;lt;/code&amp;gt;&lt;br /&gt;
* Specified hostname or ipaddress could be wrong&lt;br /&gt;
* Check databases mysql.users table. Check the host column and user rights for the user you tried to login&lt;br /&gt;
&lt;br /&gt;
== Backup ALL Databases ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -p -A &amp;gt; mysqlserver-all-db-20111016.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Backup Multiple Databases ==&lt;br /&gt;
&lt;br /&gt;
To backup specific databases, e.g. all drupal dbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysqldump -u root -p --databases drupal5 drupal6 drupal7 &amp;gt; all-drupal-db-20111016.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command to check what databases exists:&lt;br /&gt;
 mysql -u root -p -e 'SHOW DATABASES;'&lt;br /&gt;
&lt;br /&gt;
Check what tables mysqldump file includes:&lt;br /&gt;
 grep 'Database:' all-drupal-db-20111016.sql&lt;br /&gt;
&lt;br /&gt;
== MySQLDump Tips ==&lt;br /&gt;
&lt;br /&gt;
=== If MySQLDump Tool Is Not Found ===&lt;br /&gt;
&lt;br /&gt;
If you get a message: &amp;quot;mysqldump: command not found&amp;quot; try&lt;br /&gt;
 locate mysqldump&lt;br /&gt;
&lt;br /&gt;
If you find the mysql dump&lt;br /&gt;
add /usr/local/mysql-5.0.51a-linux-i686/bin/ to your users path&lt;br /&gt;
or copy the file to your /usr/bin folder, e.g.&lt;br /&gt;
 cp -a /usr/local/mysql-5.0.51a-linux-i686/bin/mysqldump /usr/bin&lt;br /&gt;
&lt;br /&gt;
If you don't have it in your computer install it by typing:&lt;br /&gt;
 sudo apt-get install mysql-client  (the most suitable version will be installed)&lt;br /&gt;
 sudo apt-get install mysql-client-5.0&lt;br /&gt;
 sudo apt-get install mysql-client-core-5.5&lt;/div&gt;</summary>
		<author><name>Creator</name></author>
		
	</entry>
</feed>