Difference between revisions of "XMission Control Panel/MySQLdump"
From XMission Wiki
(→Usage) |
(→mysqldump) |
||
Line 1: | Line 1: | ||
− | = | + | =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== | ==General== | ||
− | *Simply put, | + | *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. |
Revision as of 12:39, 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.