Mysqldump

From Wsms

Jump to: navigation, search

Note: This page should be titled mysqldump (all lowercase). It is Mysqldump due to technical limitations of Mediawiki.

mysqldump is a command-line utility for backing up mysql databases to a set of sql commands that can recreate the databases.

Sample

[ggeller@ws05 sampdb]$ mysqldump -u root -p --all-databases > backup.sql
Enter password:
[ggeller@ws05 sampdb]$ head backup.sql
-- MySQL dump 10.10
--
-- Host: localhost    Database:
-- ------------------------------------------------------
-- Server version       5.0.27

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

tips

To get the database tables, but not the actual data:

[ggeller@arthur ~]$ mysqldump --all-databases --no-data --tables --compact
...

see also

http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
20070315a
20070316a
man mysqldump

Personal tools