Difference between revisions of "XMission Control Panel/MySQLdump"
From XMission Wiki
(Created page with "=mysqldump= *mysqldump is a tool used to dump a database or a collection of databases for backup or transfer to another SQL server. It can be used to migrate databases to and ...") |
(→Usage) |
||
Line 18: | Line 18: | ||
|invokes the mysqldump command | |invokes the mysqldump command | ||
|- | |- | ||
− | |'''-u | + | |'''-u:''' |
|specifies the user to login to mysql as | |specifies the user to login to mysql as | ||
|- | |- | ||
Line 30: | Line 30: | ||
|truncates the output of the mysql command to a file | |truncates the output of the mysql command to a file | ||
|} | |} | ||
− | |||
==Switches== | ==Switches== |
Revision as of 12:38, 13 April 2016
mysqldump
- mysqldump is a tool used to dump a database or a collection of databases for backup or transfer to another SQL server. It can be used to migrate databases to and from your Cloud Servers.
General
- Simply put, mysqldump outputs the SQL statements that were used to create a database, tables and all of the data in the tables. It can output these statements in multiple formats and with more or less output information as needed.
Usage
- Since mysqldump just outputs SQL statements it is usually helpful to truncate the output to a file. A common mysqldump may look like this:
mysqldump -h localhost -u b_89756 -p databasename > databasename.sql
Looking at this command piece by piece makes it easy to understand.
mysqldump: | invokes the mysqldump command |
-u: | specifies the user to login to mysql as |
-p: | tells mysql to ask for a password |
databasename: | specifies which database to dump |
> databasename.sql: | truncates the output of the mysql command to a file |
Switches
- Different switches can be used to change the output of the mysqldump. See the following link for a list of mysqldump switches: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
Helpful Tips
- The -D switch can be used to dump a skeleton of a database without any data in it.
- The --add-drop-table switch will ensure that when the SQL is uploaded to another SQL server it drops the tables before creating them.