Mysqldump Manual In Linux Shell Comannd
mysqldump manual in linux shell comannd
mysqldump, manual, in, linux, shell, comannd
Mysqldump Manual In Linux Shell Comannd
Post Description: mysqldump manual in linux shell comannd
POST# 1036
Posted On: Fri Feb 29, 2008 12:01 pm
lucas
Topic: Mysqldump Manual In Linux Shell Comannd
how can i see the msqldump command man pages on the web? is that possible?


Tue Jan 08, 2008 9:58 am
1
mysql dump
Reply #1752
this is what i use





MYSQLDUMP(1) MySQL Database System MYSQLDUMP(1)







NNAAMMEE

mysqldump - a database backup program



SSYYNNOOPPSSIISS

mmyyssqqlldduummpp [[_o_p_t_i_o_n_s]] [[_d_b___n_a_m_e [[_t_b_l___n_a_m_e ......]]]]



DDEESSCCRRIIPPTTIIOONN

The mmyyssqqlldduummpp client is a backup program originally written by Igor

Romanenko. It can be used to dump a database or a collection of

databases for backup or for transferring the data to another SQL server

(not necessarily a MySQL server). The dump contains SQL statements to

create the table or populate it, or both.



If you are doing a backup on the server, and your tables all are MyISAM

tables, consider using the mmyyssqqllhhoottccooppyy instead because it can

accomplish faster backups and faster restores. See mmyyssqqllhhoottccooppyy(1).



There are three general ways to invoke mmyyssqqlldduummpp:



shell> mmyyssqqlldduummpp [[_o_p_t_i_o_n_s]] _d_b___n_a_m_e [[_t_a_b_l_e_s]]

shell> mmyyssqqlldduummpp [[_o_p_t_i_o_n_s]] ----ddaattaabbaasseess _d_b___n_a_m_e_1 [[_d_b___n_a_m_e_2 _d_b___n_a_m_e_3......]]

shell> mmyyssqqlldduummpp [[_o_p_t_i_o_n_s]] ----aallll--ddaattaabbaasseess



If you do not name any tables following _d_b___n_a_m_e or if you use the

----ddaattaabbaasseess or ----aallll--ddaattaabbaasseess option, entire databases are dumped.



To get a list of the options your version of mmyyssqqlldduummpp supports,

execute mmyyssqqlldduummpp ----hheellpp.



If you run mmyyssqqlldduummpp without the ----qquuiicckk or ----oopptt option, mmyyssqqlldduummpp

loads the whole result set into memory before dumping the result. This

can be a problem if you are dumping a big database. The ----oopptt option is

enabled by default, but can be disabled with ----sskkiipp--oopptt.



If you are using a recent copy of the mmyyssqqlldduummpp program to generate a

dump to be reloaded into a very old MySQL server, you should not use

the ----oopptt or ----eexxtteennddeedd--iinnsseerrtt option. Use ----sskkiipp--oopptt instead.



mmyyssqqlldduummpp supports the following options:



· ----hheellpp, --??



Display a help message and exit.



· ----aadddd--ddrroopp--ddaattaabbaassee



Add a DROP DATABASE statement before each CREATE DATABASE statement.



· ----aadddd--ddrroopp--ttaabbllee



Add a DROP TABLE statement before each CREATE TABLE statement.



· ----aadddd--lloocckkss



Surround each table dump with LOCK TABLES and UNLOCK TABLES

statements. This results in faster inserts when the dump file is

reloaded. See Section 2.16, “Speed of INSERT Statements�.



· ----aallll--ddaattaabbaasseess, --AA



Dump all tables in all databases. This is the same as using the

----ddaattaabbaasseess option and naming all the databases on the command line.



· ----aallllooww--kkeeyywwoorrddss



Allow creation of column names that are keywords. This works by

prefixing each column name with the table name.



· ----cchhaarraacctteerr--sseettss--ddiirr==_p_a_t_h



The directory where character sets are installed. See Section 9.1,

“The Character Set Used for Data and Sorting�.



· ----ccoommmmeennttss, --ii



Write additional information in the dump file such as program

version, server version, and host. . This option is enabled by

default. To suppress additional, use ----sskkiipp--ccoommmmeennttss.



· ----ccoommppaacctt



Produce less verbose output. This option suppresses comments and

enables the ----sskkiipp--aadddd--ddrroopp--ttaabbllee, ----nnoo--sseett--nnaammeess,

----sskkiipp--ddiissaabbllee--kkeeyyss, and ----sskkiipp--aadddd--lloocckkss options.



· ----ccoommppaattiibbllee==_n_a_m_e



Produce output that is more compatible with other database systems

or with older MySQL servers. The value of name can be ansi,

mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb,

no_key_options, no_table_options, or no_field_options. To use

several values, separate them by commas. These values have the same

meaning as the corresponding options for setting the server SQL

mode. See the section called “THE SERVER SQL MODE�.



This option does not guarantee compatibility with other servers. It

only enables those SQL mode values that are currently available for

making dump output more compatible. For example, ----ccoommppaattiibbllee==oorraaccllee

does not map data types to Oracle types or use Oracle comment

syntax.



· ----ccoommpplleettee--iinnsseerrtt, --cc



Use complete INSERT statements that include column names.



· ----ccoommpprreessss, --CC



Compress all information sent between the client and the server if

both support compression.



· ----ccrreeaattee--ooppttiioonnss



Include all MySQL-specific table options in the CREATE TABLE

statements.



· ----ddaattaabbaasseess, --BB



Dump several databases. Normally, mmyyssqqlldduummpp treats the first name

argument on the command line as a database name and following names

as table names. With this option, it treats all name arguments as

database names. CREATE DATABASE and USE statements are included in

the output before each new database.



· ----ddeebbuugg[[==_d_e_b_u_g___o_p_t_i_o_n_s]], --## [[_d_e_b_u_g___o_p_t_i_o_n_s]]



Write a debugging log. The _d_e_b_u_g___o_p_t_i_o_n_s string is often

´d:t:o,_f_i_l_e___n_a_m_e’. The default is ´d:t:o,/tmp/mysqldump.trace’.



· ----ddeeffaauulltt--cchhaarraacctteerr--sseett==_c_h_a_r_s_e_t___n_a_m_e



Use _c_h_a_r_s_e_t___n_a_m_e as the default character set. See Section 9.1, “The

Character Set Used for Data and Sorting�. If not specified,

mmyyssqqlldduummpp uses utf8.



· ----ddeellaayyeedd--iinnsseerrtt



Write INSERT DELAYED statements rather than INSERT statements.



· ----ddeelleettee--mmaasstteerr--llooggss



On a master replication server, delete the binary logs after

performing the dump operation. This option automatically enables

----mmaasstteerr--ddaattaa.



· ----ddiissaabbllee--kkeeyyss, --KK



For each table, surround the INSERT statements with /*!40000 ALTER

TABLE _t_b_l___n_a_m_e DISABLE KEYS */; and /*!40000 ALTER TABLE _t_b_l___n_a_m_e

ENABLE KEYS */; statements. This makes loading the dump file faster

because the indexes are created after all rows are inserted. This

option is effective for MyISAM tables only.



· ----eexxtteennddeedd--iinnsseerrtt, --ee



Use multiple-row INSERT syntax that include several VALUES lists.

This results in a smaller dump file and speeds up inserts when the

file is reloaded.



· ----ffiieellddss--tteerrmmiinnaatteedd--bbyy==......, ----ffiieellddss--eenncclloosseedd--bbyy==......,

----ffiieellddss--ooppttiioonnaallllyy--eenncclloosseedd--bbyy==......, ----ffiieellddss--eessccaappeedd--bbyy==......,

----lliinneess--tteerrmmiinnaatteedd--bbyy==......



These options are used with the --TT option and have the same meaning

as the corresponding clauses for LOAD DATA INFILE. See Section 2.5,

“LOAD DATA INFILE Syntax�.



· ----ffiirrsstt--ssllaavvee, --xx



Deprecated. Now renamed to ----lloocckk--aallll--ttaabblleess.



· ----fflluusshh--llooggss, --FF



Flush the MySQL server log files before starting the dump. This

option requires the RELOAD privilege. Note that if you use this

option in combination with the ----aallll--ddaattaabbaasseess (or --AA) option, the

logs are flushed _f_o_r _e_a_c_h _d_a_t_a_b_a_s_e _d_u_m_p_e_d. The exception is when

using ----lloocckk--aallll--ttaabblleess or ----mmaasstteerr--ddaattaa: In this case, the logs are

flushed only once, corresponding to the moment that all tables are

locked. If you want your dump and the log flush to happen at exactly

the same moment, you should use ----fflluusshh--llooggss together with either

----lloocckk--aallll--ttaabblleess or ----mmaasstteerr--ddaattaa.



· ----ffoorrccee, --ff



Continue even if an SQL error occurs during a table dump.



· ----hhoosstt==_h_o_s_t___n_a_m_e, --hh _h_o_s_t___n_a_m_e



Dump data from the MySQL server on the given host. The default host

is localhost.



· ----hheexx--bblloobb



Dump binary columns using hexadecimal notation (for example, ´abc’

becomes 0x616263). The affected data types are BINARY, VARBINARY,

and BLOB. As of MySQL 5.0.13, BIT columns are affected as well.



· ----iiggnnoorree--ttaabbllee==_d_b___n_a_m_e_._t_b_l___n_a_m_e



Do not dump the given table, which must be specified using both the

database and table names. To ignore multiple tables, use this option

multiple times.



· ----iinnsseerrtt--iiggnnoorree



Write INSERT statements with the IGNORE option.



· ----lloocckk--aallll--ttaabblleess, --xx



Lock all tables across all databases. This is achieved by acquiring

a global read lock for the duration of the whole dump. This option

automatically turns off ----ssiinnggllee--ttrraannssaaccttiioonn and ----lloocckk--ttaabblleess.



· ----lloocckk--ttaabblleess, --ll



Lock all tables before starting the dump. The tables are locked with

READ LOCAL to allow concurrent inserts in the case of MyISAM tables.

For transactional tables such as InnoDB and BDB,

----ssiinnggllee--ttrraannssaaccttiioonn is a much better option, because it does not

need to lock the tables at all.



Please note that when dumping multiple databases, ----lloocckk--ttaabblleess

locks tables for each database separately. So, this option does not

guarantee that the tables in the dump file are logically consistent

between databases. Tables in different databases may be dumped in

completely different states.



· ----mmaasstteerr--ddaattaa[[==_v_a_l_u_e]]



Write the binary log filename and position to the output. This

option requires the RELOAD privilege and the binary log must be

enabled. If the option value is equal to 1, the position and

filename are written to the dump output in the form of a CHANGE

MASTER statement that makes a slave server start from the correct

position in the master’s binary logs if you use this SQL dump of the

master to set up a slave. If the option value is equal to 2, the

CHANGE MASTER statement is written as an SQL comment. This is the

default action if _v_a_l_u_e is omitted.



The ----mmaasstteerr--ddaattaa option turns on ----lloocckk--aallll--ttaabblleess, unless

----ssiinnggllee--ttrraannssaaccttiioonn also is specified (in which case, a global read

lock is only acquired a short time at the beginning of the dump. See

also the description for ----ssiinnggllee--ttrraannssaaccttiioonn. In all cases, any

action on logs happens at the exact moment of the dump. This option

automatically turns off ----lloocckk--ttaabblleess.



· ----nnoo--aauuttooccoommmmiitt



Enclose the INSERT statements for each dumped table within SET

AUTOCOMMIT=0 and COMMIT statements.



· ----nnoo--ccrreeaattee--ddbb, --nn



This option suppresses the CREATE DATABASE statements that are

otherwise included in the output if the ----ddaattaabbaasseess or

----aallll--ddaattaabbaasseess option is given.



· ----nnoo--ccrreeaattee--iinnffoo, --tt



Do not write CREATE TABLE statements that re-create each dumped

table.



· ----nnoo--ddaattaa, --dd



Do not write any row information for the table. This is very useful

if you want to dump only the CREATE TABLE statement for the table.



· ----oopptt



This option is shorthand; it is the same as specifying

----aadddd--ddrroopp--ttaabbllee ----aadddd--lloocckkss ----ccrreeaattee--ooppttiioonnss ----ddiissaabbllee--kkeeyyss

----eexxtteennddeedd--iinnsseerrtt ----lloocckk--ttaabblleess ----qquuiicckk ----sseett--cchhaarrsseett. It should

give you a fast dump operation and produce a dump file that can be

reloaded into a MySQL server quickly.



_T_h_e ----oopptt _o_p_t_i_o_n _i_s _e_n_a_b_l_e_d _b_y _d_e_f_a_u_l_t_. _T_o _d_i_s_a_b_l_e _t_h_e _o_p_t_i_o_n_s _t_h_a_t

_i_t _e_n_a_b_l_e_s_, _u_s_e ----sskkiipp--oopptt. To disable only certain of the options

enabled by ----oopptt, use their ----sskkiipp forms; for example,

----sskkiipp--aadddd--ddrroopp--ttaabbllee or ----sskkiipp--qquuiicckk.



· ----oorrddeerr--bbyy--pprriimmaarryy



Sorts each table’s rows by its primary key, or its first unique

index, if such an index exists. This is useful when dumping a MyISAM

table to be loaded into an InnoDB table, but will make the dump

itself take considerably longer.



· ----ppaasssswwoorrdd[[==_p_a_s_s_w_o_r_d]], --pp[[_p_a_s_s_w_o_r_d]]



The password to use when connecting to the server. If you use the

short option form (--pp), you _c_a_n_n_o_t have a space between the option

and the password. If you omit the _p_a_s_s_w_o_r_d value following the

----ppaasssswwoorrdd or --pp option on the command line, you are prompted for

one.



Specifying a password on the command line should be considered

insecure. See Section 7.6, “Keeping Your Password Secure�.



· ----ppoorrtt==_p_o_r_t___n_u_m, --PP _p_o_r_t___n_u_m



The TCP/IP port number to use for the connection.



· ----pprroottooccooll=={{TTCCPP||SSOOCCKKEETT||PPIIPPEE||MMEEMMOORRYY}}



The connection protocol to use.



· ----qquuiicckk, --qq



This option is useful for dumping large tables. It forces mmyyssqqlldduummpp

to retrieve rows for a table from the server a row at a time rather

than retrieving the entire row set and buffering it in memory before

writing it out.



· ----qquuoottee--nnaammeess, --QQ



Quote database, table, and column names within ‘‘’ characters. If

the ANSI_QUOTES SQL mode is enabled, names are quoted within ‘"’

characters. This option is enabled by default. It can be disabled

with ----sskkiipp--qquuoottee--nnaammeess, but this option should be given after any

option such as ----ccoommppaattiibbllee that may enable ----qquuoottee--nnaammeess.



· ----rreessuulltt--ffiillee==_f_i_l_e, --rr _f_i_l_e



Direct output to a given file. This option should be used on Windows

to prevent newline ‘n’ characters from being converted to ‘rn’

carriage return/newline sequences.



· ----rroouuttiinneess, --RR



Dump stored routines (functions and procedures) from the dumped

databases. The output generated by using ----rroouuttiinneess contains CREATE

PROCEDURE and CREATE FUNCTION statements to re-create the routines.

However, these statements do not include attributes such as the

routine creation and modification timestamps. This means that when

the routines are reloaded, they will be created with the timestamps

equal to the reload time.



If you require routines to be re-created with their original

timestamp attributes, do not use ----rroouuttiinneess. Instead, dump and

reload the contents of the mysql.proc table directly, using a MySQL

account that has appropriate privileges for the mysql database.



This option was added in MySQL 5.0.13. Before that, stored routines

are not dumped. Routine DEFINER values are not dumped until MySQL

5.0.20. This means that before 5.0.20, when routines are reloaded,

they will be created with the definer set to the reloading user. If

you require routines to be re-created with their original definer,

dump and load the contents of the mysql.proc table directly as

described earlier.



· ----sseett--cchhaarrsseett



Add SET NAMES _d_e_f_a_u_l_t___c_h_a_r_a_c_t_e_r___s_e_t to the output. This option is

enabled by default. To suppress the SET NAMES statement, use

----sskkiipp--sseett--cchhaarrsseett.



· ----ssiinnggllee--ttrraannssaaccttiioonn



This option issues a BEGIN SQL statement before dumping data from

the server. It is useful only with transactional tables such as

InnoDB and BDB, because then it dumps the consistent state of the

database at the time when BEGIN was issued without blocking any

applications.



When using this option, you should keep in mind that only InnoDB

tables are dumped in a consistent state. For example, any MyISAM or

MEMORY tables dumped while using this option may still change state.



The ----ssiinnggllee--ttrraannssaaccttiioonn option and the ----lloocckk--ttaabblleess option are

mutually exclusive, because LOCK TABLES causes any pending

transactions to be committed implicitly.



To dump big tables, you should combine this option with ----qquuiicckk.



· ----ssoocckkeett==_p_a_t_h, --SS _p_a_t_h



For connections to localhost, the Unix socket file to use, or, on

Windows, the name of the named pipe to use.



· ----sskkiipp--ccoommmmeennttss



See the description for the ----ccoommmmeennttss option.



· ----ssssll**



Options that begin with ----ssssll specify whether to connect to the

server via SSL and indicate where to find SSL keys and certificates.

See Section 7.7.3, “SSL Command Options�.



· ----ttaabb==_p_a_t_h, --TT _p_a_t_h



Produce tab-separated data files. For each dumped table, mmyyssqqlldduummpp

creates a _t_b_l___n_a_m_e_._s_q_l file that contains the CREATE TABLE statement

that creates the table, and a _t_b_l___n_a_m_e_._t_x_t file that contains its

data. The option value is the directory in which to write the files.



By default, the _._t_x_t data files are formatted using tab characters

between column values and a newline at the end of each line. The

format can be specified explicitly using the ----ffiieellddss--_x_x_x and

----lliinneess----_x_x_x options.



NNoottee: This option should be used only when mmyyssqqlldduummpp is run on the

same machine as the mmyyssqqlldd server. You must have the FILE privilege,

and the server must have permission to write files in the directory

that you specify.



· ----ttaabblleess



Override the ----ddaattaabbaasseess or --BB option. All name arguments following

the option are regarded as table names.



· ----ttrriiggggeerrss



Dump triggers for each dumped table. This option is enabled by

default; disable it with ----sskkiipp--ttrriiggggeerrss. This option was added in

MySQL 5.0.11. Before that, triggers are not dumped.



· ----ttzz--uuttcc



Add SET TIME_ZONE=’+00:00’ to the dump file so that TIMESTAMP

columns can be dumped and reloaded between servers in different time

zones. Without this option, TIMESTAMP columns are dumped and

reloaded in the time zones local to the source and destination

servers, which can cause the values to change. ----ttzz--uuttcc also

protects against changes due to daylight saving time. ----ttzz--uuttcc is

enabled by default. To disable it, use ----sskkiipp--ttzz--uuttcc. This option

was added in MySQL 5.0.15.



· ----uusseerr==_u_s_e_r___n_a_m_e, --uu _u_s_e_r___n_a_m_e



The MySQL username to use when connecting to the server.



· ----vveerrbboossee, --vv



Verbose mode. Print more information about what the program does.



· ----vveerrssiioonn, --VV



Display version information and exit.



· ----wwhheerree==’’_w_h_e_r_e___c_o_n_d_i_t_i_o_n’’, --ww ’’_w_h_e_r_e___c_o_n_d_i_t_i_o_n’’



Dump only rows selected by the given WHERE condition. Note that

quotes around the condition are mandatory if it contains spaces or

other characters that are special to your command interpreter.



Examples:



--where="user=’jimf’"

-w"userid>1"

-w"userid<1"



· ----xxmmll, --XX



Write dump output as well-formed XML.



You can also set the following variables by using ----_v_a_r___n_a_m_e==_v_a_l_u_e

syntax:



· max_allowed_packet



The maximum size of the buffer for client/server communication. The

maximum is 1GB.



· net_buffer_length



The initial size of the buffer for client/server communication. When

creating multiple-row-insert statements (as with option

----eexxtteennddeedd--iinnsseerrtt or ----oopptt), mmyyssqqlldduummpp creates rows up to

net_buffer_length length. If you increase this variable, you should

also ensure that the net_buffer_length variable in the MySQL server

is at least this large.



It is also possible to set variables by using

----sseett--vvaarriiaabbllee==_v_a_r___n_a_m_e==_v_a_l_u_e or --OO _v_a_r___n_a_m_e==_v_a_l_u_e syntax. _T_h_i_s _s_y_n_t_a_x

_i_s _d_e_p_r_e_c_a_t_e_d.



The most common use of mmyyssqqlldduummpp is probably for making a backup of an

entire database:



shell> mmyyssqqlldduummpp ----oopptt _d_b___n_a_m_e >> _b_a_c_k_u_p_-_f_i_l_e_._s_q_l



You can read the dump file back into the server like this:



shell> mmyyssqqll _d_b___n_a_m_e << _b_a_c_k_u_p_-_f_i_l_e_._s_q_l



Or like this:



shell> mmyyssqqll --ee ""ssoouurrccee _/_p_a_t_h_-_t_o_-_b_a_c_k_u_p_/_b_a_c_k_u_p_-_f_i_l_e_._s_q_l"" _d_b___n_a_m_e



mmyyssqqlldduummpp is also very useful for populating databases by copying data

from one MySQL server to another:



shell> mmyyssqqlldduummpp ----oopptt _d_b___n_a_m_e || mmyyssqqll ----hhoosstt==_r_e_m_o_t_e___h_o_s_t --CC _d_b___n_a_m_e



It is possible to dump several databases with one command:



shell> mmyyssqqlldduummpp ----ddaattaabbaasseess _d_b___n_a_m_e_1 [[_d_b___n_a_m_e_2 ......]] >> mmyy__ddaattaabbaasseess..ssqqll



To dump all databases, use the ----aallll--ddaattaabbaasseess option:



shell> mmyyssqqlldduummpp ----aallll--ddaattaabbaasseess >> aallll__ddaattaabbaasseess..ssqqll



For InnoDB tables, mysqldump provides a way of making an online backup:



shell> mmyyssqqlldduummpp ----aallll--ddaattaabbaasseess ----ssiinnggllee--ttrraannssaaccttiioonn >> aallll__ddaattaabbaasseess..ssqqll



This backup just needs to acquire a global read lock on all tables

(using FLUSH TABLES WITH READ LOCK) at the beginning of the dump. As

soon as this lock has been acquired, the binary log coordinates are

read and the lock is released. If and only if one long updating

statement is running when the FLUSH statement is issued, the MySQL

server may get stalled until that long statement finishes, and then the

dump becomes lock-free. If the update statements that the MySQL server

receives are short (in terms of execution time), the initial lock

period should not be noticeable, even with many updates.



For point-in-time recovery (also known as “roll-forward,� when you need

to restore an old backup and replay the changes that happened since

that backup), it is often useful to rotate the binary log (see

Section 10.3, “The Binary Log�) or at least know the binary log

coordinates to which the dump corresponds:



shell> mmyyssqqlldduummpp ----aallll--ddaattaabbaasseess ----mmaasstteerr--ddaattaa==22 >> aallll__ddaattaabbaasseess..ssqqll



Or:



shell> mmyyssqqlldduummpp ----aallll--ddaattaabbaasseess ----fflluusshh--llooggss ----mmaasstteerr--ddaattaa==22

>> aallll__ddaattaabbaasseess..ssqqll



The simultaneous use of ----mmaasstteerr--ddaattaa and ----ssiinnggllee--ttrraannssaaccttiioonn provides

a convenient way to make an online backup suitable for point-in-time

recovery if tables are stored in the InnoDB storage engine.



For more information on making backups, see Section 8.1, “Database

Backups�, and Section 8.2, “Example Backup and Recovery Strategy�.



SSEEEE AALLSSOO

msql2mysql(1), myisam_ftdump(1), myisamchk(1), myisamlog(1),

myisampack(1), mysql(1), mysql.server(1), mysql_config(1),

mysql_fix_privilege_tables(1), mysql_upgrade(1), mysql_zap(1),

mysqlaccess(1), mysqladmin(1), mysqlbinlog(1), mysqlcheck(1),

mysqld(1), mysqld_multi(1), mysqld_safe(1), mysqlhotcopy(1),

mysqlimport(1), mysqlmanager(1), mysqlshow(1), perror(1), replace(1),

safe_mysqld(1)



For more information, please refer to the MySQL Reference Manual, which

may already be installed locally and which is also available online at

http://dev.mysql.com/doc/.



AAUUTTHHOORR

MySQL AB (http://www.mysql.com/). This software comes with no

warranty.







MySQL 5.0 05/24/2006 MYSQLDUMP(1)



What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload