<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dreamvib ~ music lounge &#187; server</title>
	<atom:link href="http://music.dreamvib.com/category/programming/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://music.dreamvib.com</link>
	<description></description>
	<lastBuildDate>Fri, 12 Jun 2009 08:31:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>mysqldump</title>
		<link>http://music.dreamvib.com/programming/mysql/mysqldump/</link>
		<comments>http://music.dreamvib.com/programming/mysql/mysqldump/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 08:05:53 +0000</pubDate>
		<dc:creator>dreamvib</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.dreamvib.com/?p=14</guid>
		<description><![CDATA[Name
mysqldump &#8211; a database backup program
Synopsis

mysqldump [options] [db_name [tbl_name ...]]

Description
The mysqldump 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 [...]]]></description>
			<content:encoded><![CDATA[<h2>Name</h2>
<p>mysqldump &#8211; a database backup program</p>
<h2>Synopsis</h2>
<dl compact="compact">
<dt><strong>mysqldump [<em>options</em>] [<em>db_name</em> [<em>tbl_name</em> ...]]</strong></dt>
</dl>
<h2>Description</h2>
<p>The <strong>mysqldump</strong> client is a backup program originally written by Igor Romanenko. It can be used to <span class="highlight1">dump</span> a database or a collection of databases for backup or for transferring the data to another SQL server (not necessarily a <span class="highlight0">MySQL</span> server). The <span class="highlight1">dump</span> contains SQL statements to create the table or populate it, or both.</p>
<p>If you are doing a backup on the server, and your tables all are MyISAM tables, consider using the <strong>mysqlhotcopy</strong> instead because it can accomplish faster backups and faster restores. See <em><strong><a href="http://linux.die.net/man/1/mysqlhotcopy" rel="nofollow">mysqlhotcopy</a></strong>(1)</em>.</p>
<p>There are three general ways to invoke <strong>mysqldump</strong>:</p>
<pre class="code">shell&gt; mysqldump [options] db_name [tables]
shell&gt; mysqldump [options] --databases db_name1 [db_name2 db_name3...]
shell&gt; mysqldump [options] --all-databases</pre>
<p>If you do not name any tables following <em>db_name</em> or if you use the <strong>&#8211;databases</strong> or <strong>&#8211;all-databases</strong> option, entire databases are dumped.To get a list of the options your version of <strong>mysqldump</strong> supports, execute <strong>mysqldump &#8211;help</strong>.</p>
<p>If you run <strong>mysqldump</strong> without the <strong>&#8211;quick</strong> or <strong>&#8211;opt</strong> option, <strong>mysqldump</strong> loads the whole result set into memory before dumping the result. This can be a problem if you are dumping a big database. The <strong>&#8211;opt</strong> option is enabled by default, but can be disabled with <strong>&#8211;skip-opt</strong>.</p>
<p>If you are using a recent copy of the <strong>mysqldump</strong> program to generate a <span class="highlight1">dump</span> to be reloaded into a very old <span class="highlight0">MySQL</span> server, you should not use the <strong>&#8211;opt</strong> or <strong>&#8211;extended-insert</strong> option. Use <strong>&#8211;skip-opt</strong> instead.</p>
<p><strong>mysqldump</strong> supports the following options:</p>
<ul>
<li><strong>&#8211;help</strong>, <strong>-?</strong>Display a help message and exit.</li>
<li><strong>&#8211;add-drop-database</strong>Add a DROP DATABASE statement before each CREATE DATABASE statement.</li>
<li><strong>&#8211;add-drop-table</strong>Add a DROP TABLE statement before each CREATE TABLE statement.</li>
<li><strong>&#8211;add-locks</strong>Surround each table <span class="highlight1">dump</span> with LOCK TABLES and UNLOCK TABLES statements. This results <span class="highlight2">in</span> faster inserts when the <span class="highlight1">dump</span> file is reloaded. See Section 2.16, lqSpeed of INSERT Statementsrq.</li>
<li><strong>&#8211;all-databases</strong>, <strong>-A</strong><span class="highlight1">Dump</span> all tables <span class="highlight2">in</span> all databases. This is the same as using the <strong>&#8211;databases</strong> option and naming all the databases on the command line.</li>
<li><strong>&#8211;allow-keywords</strong>Allow creation of column names that are keywords. This works by prefixing each column name with the table name.</li>
<li><strong>&#8211;character-sets-dir=<em>path</em></strong>The directory where character sets are installed. See Section 9.1, lqThe Character Set Used for Data and Sortingrq.</li>
<li><strong>&#8211;comments</strong>, <strong>-i</strong>Write additional information <span class="highlight2">in</span> the <span class="highlight1">dump</span> file such as program version, server version, and host. . This option is enabled by default. To suppress additional, use <strong>&#8211;skip-comments</strong>.</li>
<li><strong>&#8211;compact</strong>Produce less verbose output. This option suppresses comments and enables the <strong>&#8211;skip-add-drop-table</strong>, <strong>&#8211;no-set-names</strong>, <strong>&#8211;skip-disable-keys</strong>, and <strong>&#8211;skip-add-locks</strong> options.</li>
<li><strong>&#8211;compatible=<em>name</em></strong>Produce output that is more compatible with other database systems or with older <span class="highlight0">MySQL</span> 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 lqTHE SERVER SQL MODErq.
<p>This option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making <span class="highlight1">dump</span> output more compatible. For example, <strong>&#8211;compatible=oracle</strong> does not map data types to Oracle types or use Oracle comment syntax.</li>
<li><strong>&#8211;complete-insert</strong>, <strong>-c</strong>Use complete INSERT statements that include column names.</li>
<li><strong>&#8211;compress</strong>, <strong>-C</strong>Compress all information sent between the client and the server if both support compression.</li>
<li><strong>&#8211;create-options</strong>Include all <span class="highlight0">MySQL</span>-specific table options <span class="highlight2">in</span> the CREATE TABLE statements.</li>
<li><strong>&#8211;databases</strong>, <strong>-B</strong><span class="highlight1">Dump</span> several databases. Normally, <strong>mysqldump</strong> 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 <span class="highlight2">in</span> the output before each new database.</li>
<li><strong>&#8211;debug[=<em>debug_options</em>]</strong>, <strong>-# [<em>debug_options</em>]</strong>Write a debugging log. The <em>debug_options</em> string is often &#8216;d:t:o,<em>file_name</em>&#8216;. The default is &#8216;d:t:o,/tmp/mysqldump.trace&#8217;.</li>
<li><strong>&#8211;default-character-set=<em>charset_name</em></strong>Use <em>charset_name</em> as the default character set. See Section 9.1, lqThe Character Set Used for Data and Sortingrq. If not specified, <strong>mysqldump</strong> uses utf8.</li>
<li><strong>&#8211;delayed-insert</strong>Write INSERT DELAYED statements rather than INSERT statements.</li>
<li><strong>&#8211;delete-master-logs</strong>On a master replication server, delete the binary logs after performing the <span class="highlight1">dump</span> operation. This option automatically enables <strong>&#8211;master-data</strong>.</li>
<li><strong>&#8211;disable-keys</strong>, <strong>-K</strong>For each table, surround the INSERT statements with /*!40000 ALTER TABLE <em>tbl_name</em> DISABLE KEYS */; and /*!40000 ALTER TABLE <em>tbl_name</em> ENABLE KEYS */; statements. This makes loading the <span class="highlight1">dump</span> file faster because the indexes are created after all rows are inserted. This option is effective for MyISAM tables only.</li>
<li><strong>&#8211;extended-insert</strong>, <strong>-e</strong>Use multiple-row INSERT syntax that include several VALUES lists. This results <span class="highlight2">in</span> a smaller <span class="highlight1">dump</span> file and speeds up inserts when the file is reloaded.</li>
<li><strong>&#8211;fields-terminated-by=&#8230;</strong>, <strong>&#8211;fields-enclosed-by=&#8230;</strong>, <strong>&#8211;fields-optionally-enclosed-by=&#8230;</strong>, <strong>&#8211;fields-escaped-by=&#8230;</strong>, <strong>&#8211;lines-terminated-by=&#8230;</strong>These options are used with the <strong>-T</strong> option and have the same meaning as the corresponding clauses for LOAD DATA INFILE. See Section 2.5, lqLOAD DATA INFILE Syntaxrq.</li>
<li><strong>&#8211;first-slave</strong>, <strong>-x</strong>Deprecated. Now renamed to <strong>&#8211;lock-all-tables</strong>.</li>
<li><strong>&#8211;flush-logs</strong>, <strong>-F</strong>Flush the <span class="highlight0">MySQL</span> server log files before starting the <span class="highlight1">dump</span>. This option requires the RELOAD privilege. Note that if you use this option <span class="highlight2">in</span> combination with the <strong>&#8211;all-databases</strong> (or <strong>-A</strong>) option, the logs are flushed <em>for each database dumped</em>. The exception is when using <strong>&#8211;lock-all-tables</strong> or <strong>&#8211;master-data</strong>: <span class="highlight2">In</span> this case, the logs are flushed only once, corresponding to the moment that all tables are locked. If you want your <span class="highlight1">dump</span> and the log flush to happen at exactly the same moment, you should use <strong>&#8211;flush-logs</strong> together with either <strong>&#8211;lock-all-tables</strong> or <strong>&#8211;master-data</strong>.</li>
<li><strong>&#8211;force</strong>, <strong>-f</strong>Continue even if an SQL error occurs during a table <span class="highlight1">dump</span>.</li>
<li><strong>&#8211;host=<em>host_name</em></strong>, <strong>-h <em>host_name</em></strong><span class="highlight1">Dump</span> data from the <span class="highlight0">MySQL</span> server on the given host. The default host is localhost.</li>
<li><strong>&#8211;hex-blob</strong><span class="highlight1">Dump</span> binary columns using hexadecimal notation (for example, &#8216;abc&#8217; becomes 0&#215;616263). The affected data types are BINARY, VARBINARY, and BLOB. As of <span class="highlight0">MySQL</span> 5.0.13, BIT columns are affected as well.</li>
<li><strong>&#8211;ignore-table=<em>db_name.tbl_name</em></strong>Do not <span class="highlight1">dump</span> the given table, which must be specified using both the database and table names. To ignore multiple tables, use this option multiple times.</li>
<li><strong>&#8211;insert-ignore</strong>Write INSERT statements with the IGNORE option.</li>
<li><strong>&#8211;lock-all-tables</strong>, <strong>-x</strong>Lock all tables across all databases. This is achieved by acquiring a global read lock for the duration of the whole <span class="highlight1">dump</span>. This option automatically turns off <strong>&#8211;single-transaction</strong> and <strong>&#8211;lock-tables</strong>.</li>
<li><strong>&#8211;lock-tables</strong>, <strong>-l</strong>Lock all tables before starting the <span class="highlight1">dump</span>. The tables are locked with READ LOCAL to allow concurrent inserts <span class="highlight2">in</span> the case of MyISAM tables. For transactional tables such as InnoDB and BDB, <strong>&#8211;single-transaction</strong> is a much better option, because it does not need to lock the tables at all.
<p>Please note that when dumping multiple databases, <strong>&#8211;lock-tables</strong> locks tables for each database separately. So, this option does not guarantee that the tables <span class="highlight2">in</span> the <span class="highlight1">dump</span> file are logically consistent between databases. Tables <span class="highlight2">in</span> different databases may be dumped <span class="highlight2">in</span> completely different states.</li>
<li><strong>&#8211;master-data[=<em>value</em>]</strong>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 <span class="highlight1">dump</span> output <span class="highlight2">in</span> the form of a CHANGE MASTER statement that makes a slave server start from the correct position <span class="highlight2">in</span> the master&#8217;s binary logs if you use this SQL <span class="highlight1">dump</span> 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 <em>value</em> is omitted.
<p>The <strong>&#8211;master-data</strong> option turns on <strong>&#8211;lock-all-tables</strong>, unless <strong>&#8211;single-transaction</strong> also is specified (<span class="highlight2">in</span> which case, a global read lock is only acquired a short time at the beginning of the <span class="highlight1">dump</span>. See also the description for <strong>&#8211;single-transaction</strong>. <span class="highlight2">In</span> all cases, any action on logs happens at the exact moment of the <span class="highlight1">dump</span>. This option automatically turns off <strong>&#8211;lock-tables</strong>.</li>
<li><strong>&#8211;no-autocommit</strong>Enclose the INSERT statements for each dumped table within SET AUTOCOMMIT=0 and COMMIT statements.</li>
<li><strong>&#8211;no-create-db</strong>, <strong>-n</strong>This option suppresses the CREATE DATABASE statements that are otherwise included <span class="highlight2">in</span> the output if the <strong>&#8211;databases</strong> or <strong>&#8211;all-databases</strong> option is given.</li>
<li><strong>&#8211;no-create-info</strong>, <strong>-t</strong>Do not write CREATE TABLE statements that re-create each dumped table.</li>
<li><strong>&#8211;no-data</strong>, <strong>-d</strong>Do not write any row information for the table. This is very useful if you want to <span class="highlight1">dump</span> only the CREATE TABLE statement for the table.</li>
<li><strong>&#8211;opt</strong>This option is shorthand; it is the same as specifying <strong>&#8211;add-drop-table &#8211;add-locks &#8211;create-options &#8211;disable-keys &#8211;extended-insert &#8211;lock-tables &#8211;quick &#8211;set-charset</strong>. It should give you a fast <span class="highlight1">dump</span> operation and produce a <span class="highlight1">dump</span> file that can be reloaded into a <span class="highlight0">MySQL</span> server quickly.
<p><em>The <strong>&#8211;opt</strong> option is enabled by default. To disable the options that it enables, use <strong>&#8211;skip-opt</strong></em>. To disable only certain of the options enabled by <strong>&#8211;opt</strong>, use their <strong>&#8211;skip</strong> forms; for example, <strong>&#8211;skip-add-drop-table</strong> or <strong>&#8211;skip-quick</strong>.</li>
<li><strong>&#8211;order-by-primary</strong>Sorts each table&#8217;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 <span class="highlight1">dump</span> itself take considerably longer.</li>
<li><strong>&#8211;password[=<em>password</em>]</strong>, <strong>-p[<em>password</em>]</strong>The password to use when connecting to the server. If you use the short option form (<strong>-p</strong>), you <em>cannot</em> have a space between the option and the password. If you omit the <em>password</em> value following the <strong>&#8211;password</strong> or <strong>-p</strong> option on the command line, you are prompted for one.
<p>Specifying a password on the command line should be considered insecure. See Section 7.6, lqKeeping Your Password Securerq.</li>
<li style="list-style-type: none; list-style-image: none; list-style-position: outside">Â·</li>
<li><strong>&#8211;port=<em>port_num</em></strong>, <strong>-P <em>port_num</em></strong>The TCP/IP port number to use for the connection.</li>
<li><strong>&#8211;protocol={TCP|SOCKET|PIPE|MEMORY}</strong>The connection protocol to use.</li>
<li><strong>&#8211;quick</strong>, <strong>-q</strong>This option is useful for dumping large tables. It forces <strong>mysqldump</strong> to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it <span class="highlight2">in</span> memory before writing it out.</li>
<li><strong>&#8211;quote-names</strong>, <strong>-Q</strong>Quote database, table, and column names within oq&#8217;cq characters. If the ANSI_QUOTES SQL mode is enabled, names are quoted within oq&#8221;cq characters. This option is enabled by default. It can be disabled with <strong>&#8211;skip-quote-names</strong>, but this option should be given after any option such as <strong>&#8211;compatible</strong> that may enable <strong>&#8211;quote-names</strong>.</li>
<li><strong>&#8211;result-file=<em>file</em></strong>, <strong>-r <em>file</em></strong>Direct output to a given file. This option should be used on Windows to prevent newline oq\ncq characters from being converted to oq\r\ncq carriage return/newline sequences.</li>
<li><strong>&#8211;routines</strong>, <strong>-R</strong><span class="highlight1">Dump</span> stored routines (functions and procedures) from the dumped databases. The output generated by using <strong>&#8211;routines</strong> 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.
<p>If you require routines to be re-created with their original timestamp attributes, do not use <strong>&#8211;routines</strong>. Instead, <span class="highlight1">dump</span> and reload the contents of the <span class="highlight0">mysql</span>.proc table directly, using a <span class="highlight0">MySQL</span> account that has appropriate privileges for the <span class="highlight0">mysql</span> database.</p>
<p>This option was added <span class="highlight2">in</span> <span class="highlight0">MySQL</span> 5.0.13. Before that, stored routines are not dumped. Routine DEFINER values are not dumped until <span class="highlight0">MySQL</span> 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, <span class="highlight1">dump</span> and load the contents of the <span class="highlight0">mysql</span>.proc table directly as described earlier.</li>
<li><strong>&#8211;set-charset</strong>Add SET NAMES <em>default_character_set</em> to the output. This option is enabled by default. To suppress the SET NAMES statement, use <strong>&#8211;skip-set-charset</strong>.</li>
<li><strong>&#8211;single-transaction</strong>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 <span class="highlight1">dumps</span> the consistent state of the database at the time when BEGIN was issued without blocking any applications.
<p>When using this option, you should keep <span class="highlight2">in</span> mind that only InnoDB tables are dumped <span class="highlight2">in</span> a consistent state. For example, any MyISAM or MEMORY tables dumped while using this option may still change state.</p>
<p>The <strong>&#8211;single-transaction</strong> option and the <strong>&#8211;lock-tables</strong> option are mutually exclusive, because LOCK TABLES causes any pending transactions to be committed implicitly.</p>
<p>To <span class="highlight1">dump</span> big tables, you should combine this option with <strong>&#8211;quick</strong>.</li>
<li><strong>&#8211;socket=<em>path</em></strong>, <strong>-S <em>path</em></strong>For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.</li>
<li><strong>&#8211;skip-comments</strong>See the description for the <strong>&#8211;comments</strong> option.</li>
<li><strong>&#8211;ssl*</strong>Options that begin with <strong>&#8211;ssl</strong> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See Section 7.7.3, lqSSL Command Optionsrq.</li>
<li style="list-style-type: none; list-style-image: none; list-style-position: outside">Â·</li>
<li><strong>&#8211;tab=<em>path</em></strong>, <strong>-T <em>path</em></strong>Produce tab-separated data files. For each dumped table, <strong>mysqldump</strong> creates a <em>tbl_name.sql</em> file that contains the CREATE TABLE statement that creates the table, and a <em>tbl_name.txt</em> file that contains its data. The option value is the directory <span class="highlight2">in</span> which to write the files.
<p>By default, the <em>.txt</em> 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 <strong>&#8211;fields-<em>xxx</em></strong> and <strong>&#8211;lines&#8211;<em>xxx</em></strong> options.</p>
<p><strong>Note</strong>: This option should be used only when <strong>mysqldump</strong> is run on the same machine as the <strong>mysqld</strong> server. You must have the FILE privilege, and the server must have permission to write files <span class="highlight2">in</span> the directory that you specify.</li>
<li><strong>&#8211;tables</strong>Override the <strong>&#8211;databases</strong> or <strong>-B</strong> option. All name arguments following the option are regarded as table names.</li>
<li><strong>&#8211;triggers</strong><span class="highlight1">Dump</span> triggers for each dumped table. This option is enabled by default; disable it with <strong>&#8211;skip-triggers</strong>. This option was added <span class="highlight2">in</span> <span class="highlight0">MySQL</span> 5.0.11. Before that, triggers are not dumped.</li>
<li><strong>&#8211;tz-utc</strong>Add SET TIME_ZONE=&#8217;+00:00&#8242; to the <span class="highlight1">dump</span> file so that TIMESTAMP columns can be dumped and reloaded between servers <span class="highlight2">in</span> different time zones. Without this option, TIMESTAMP columns are dumped and reloaded <span class="highlight2">in</span> the time zones local to the source and destination servers, which can cause the values to change. <strong>&#8211;tz-utc</strong> also protects against changes due to daylight saving time. <strong>&#8211;tz-utc</strong> is enabled by default. To disable it, use <strong>&#8211;skip-tz-utc</strong>. This option was added <span class="highlight2">in</span> <span class="highlight0">MySQL</span> 5.0.15.</li>
<li><strong>&#8211;user=<em>user_name</em></strong>, <strong>-u <em>user_name</em></strong>The <span class="highlight0">MySQL</span> username to use when connecting to the server.</li>
<li><strong>&#8211;verbose</strong>, <strong>-v</strong>Verbose mode. Print more information about what the program does.</li>
<li><strong>&#8211;version</strong>, <strong>-V</strong>Display version information and exit.</li>
<li><strong>&#8211;where=&#8217;<em>where_condition</em>&#8216;</strong>, <strong>-w &#8216;<em>where_condition</em>&#8216;</strong><span class="highlight1">Dump</span> 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.
<p>Examples:</p>
<pre class="code">--where="user='jimf'"
-w"userid&gt;1"
-w"userid&lt;1"</pre>
</li>
<li><strong>&#8211;xml</strong>, <strong>-X</strong>Write <span class="highlight1">dump</span> output as well-formed XML.</li>
</ul>
<p>You can also set the following variables by using <strong>&#8211;<em>var_name</em>=<em>value</em></strong> syntax:</p>
<ul>
<li>max_allowed_packetThe maximum size of the buffer for client/server communication. The maximum is 1GB.</li>
<li>net_buffer_lengthThe initial size of the buffer for client/server communication. When creating multiple-row-insert statements (as with option <strong>&#8211;extended-insert</strong> or <strong>&#8211;opt</strong>), <strong>mysqldump</strong> creates rows up to net_buffer_length length. If you increase this variable, you should also ensure that the net_buffer_length variable <span class="highlight2">in</span> the <span class="highlight0">MySQL</span> server is at least this large.</li>
</ul>
<p>It is also possible to set variables by using <strong>&#8211;set-variable=<em>var_name</em>=<em>value</em></strong> or <strong>-O <em>var_name</em>=<em>value</em></strong> syntax. <em>This syntax is deprecated</em>.</p>
<p>The most common use of <strong>mysqldump</strong> is probably for making a backup of an entire database:</p>
<pre class="code">shell&gt; mysqldump --opt db_name &gt; backup-file.sql</pre>
<p>You can read the <span class="highlight1">dump</span> file back into the server like this:</p>
<pre class="code">shell&gt; <span class="highlight0">mysql</span> db_name &lt; backup-file.sql</pre>
<p>Or like this:</p>
<pre class="code">shell&gt; <span class="highlight0">mysql</span> -e "source /path-to-backup/backup-file.sql" db_name</pre>
<p><strong>mysqldump</strong> is also very useful for populating databases by copying data from one <span class="highlight0">MySQL</span> server to another:</p>
<pre class="code">shell&gt; mysqldump --opt db_name | <span class="highlight0">mysql</span> --host=remote_host -C db_name</pre>
<p>It is possible to <span class="highlight1">dump</span> several databases with one command:</p>
<pre class="code">shell&gt; mysqldump --databases db_name1 [db_name2 ...] &gt; my_databases.sql</pre>
<p>To <span class="highlight1">dump</span> all databases, use the <strong>&#8211;all-databases</strong> option:</p>
<pre class="code">shell&gt; mysqldump --all-databases &gt; all_databases.sql</pre>
<p>For InnoDB tables, mysqldump provides a way of making an online backup:</p>
<pre class="code">shell&gt; mysqldump --all-databases --single-transaction &gt; all_databases.sql</pre>
<p>This backup just needs to acquire a global read lock on all tables (using FLUSH TABLES WITH READ LOCK) at the beginning of the <span class="highlight1">dump</span>. 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 <span class="highlight0">MySQL</span> server may get stalled until that long statement finishes, and then the <span class="highlight1">dump</span> becomes lock-free. If the update statements that the <span class="highlight0">MySQL</span> server receives are short (<span class="highlight2">in</span> terms of execution time), the initial lock period should not be noticeable, even with many updates.For point-<span class="highlight2">in</span>-time recovery (also known as lqroll-forward,rq 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, lqThe Binary Logrq) or at least know the binary log coordinates to which the <span class="highlight1">dump</span> corresponds:</p>
<pre class="code">shell&gt; mysqldump --all-databases --master-data=2 &gt; all_databases.sql</pre>
<p>Or:</p>
<pre class="code">shell&gt; mysqldump --all-databases --flush-logs --master-data=2
              &gt; all_databases.sql</pre>
<p>The simultaneous use of <strong>&#8211;master-data</strong> and <strong>&#8211;single-transaction</strong> provides a convenient way to make an online backup suitable for point-<span class="highlight2">in</span>-time recovery if tables are stored <span class="highlight2">in</span> the InnoDB storage engine.</p>
<p>source: <a href="http://linux.die.net/man/1/mysqldump" target="_blank">http://linux.die.net/man/1/mysqldump</a></p>
]]></content:encoded>
			<wfw:commentRss>http://music.dreamvib.com/programming/mysql/mysqldump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux/ unix rm command</title>
		<link>http://music.dreamvib.com/computer/softwares/linux-unix-rm-command/</link>
		<comments>http://music.dreamvib.com/computer/softwares/linux-unix-rm-command/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 03:27:36 +0000</pubDate>
		<dc:creator>dreamvib</dc:creator>
				<category><![CDATA[glossary]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[softwares]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[linux commands]]></category>

		<guid isPermaLink="false">http://blog.dreamvib.com/?p=12</guid>
		<description><![CDATA[



Linux / Unix rm command



Quick links
About                 rm
Syntax
Examples
Related commands
Unix                 main page
About rm
Deletes             [...]]]></description>
			<content:encoded><![CDATA[<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="icell"></td>
<td width="100%">
<h1>Linux / Unix rm command</h1>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" width="80%">
<p class="nb">Quick links</p>
<p class="tab"><a href="http://www.computerhope.com/unix/urm.htm#01">About                 rm</a><br />
<a href="http://www.computerhope.com/unix/urm.htm#02">Syntax</a><br />
<a href="http://www.computerhope.com/unix/urm.htm#03">Examples<br />
</a><a href="http://www.computerhope.com/unix/urm.htm#04">Related commands<br />
</a><a href="http://www.computerhope.com/unix.htm">Unix                 main page</a></p>
<p class="nb"><a title="01" name="01"></a>About rm</p>
<p>Deletes               a file without             confirmation (by default).</p>
<p class="nb"><a title="02" name="02"></a>Syntax</p>
<p><em>rm [-f] [-i] [-R] [-r]               [filenames | directory]</em></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" width="120">-f</td>
<td valign="top">Remove all files (whether write-protected or not) in a directory without prompting the user. In a write-protected directory, however, files are never removed (whatever their permissions are), but no messages are displayed. If the removal of a write-protected directory is attempted, this option will not suppress an error message.</td>
</tr>
<tr>
<td valign="top" width="120">-i</td>
<td valign="top">Interactive. With this option, rm prompts for confirmation before removing any files. It over- rides the -f option and remains in effect even if the standard input is not a terminal.</td>
</tr>
<tr>
<td valign="top" width="120">-R</td>
<td valign="top">Same as -r option.</td>
</tr>
<tr>
<td valign="top" width="120">-r</td>
<td valign="top">Recursively remove directories and subdirectories in the argument list. The directory will be emptied of files and removed. The user is normally prompted for removal of any write-protected files which the directory contains. The write-protected files are removed without prompting, however, if the -f option is used, or if the standard input is not a terminal and the -i option is not used.  Symbolic links that are encountered with this option will not be traversed.  If the removal of a non-empty, write-protected directory is attempted, the utility will always fail (even if the -f option is used), resulting in an error message.</td>
</tr>
<tr>
<td valign="top" width="120">filenames</td>
<td valign="top">A path                     of a filename to be removed.</td>
</tr>
</table>
<p class="nb"><a title="03" name="03"></a>Examples</p>
<p><strong>rm myfile.txt</strong></p>
<p>Remove the file myfile.txt             without prompting the user.</p>
<p><strong>rm -r directory</strong></p>
<p>Remove a directory, even             if files existed in that directory.</p>
<p>Note that if you use rm to remove a file, it is  			usually possible to recover the contents of that file. If you want  			more assurance that the contents are truly unrecoverable, consider  			using <a href="http://www.computerhope.com/unix/shred.htm">shre</a></td>
</tr>
</table>
</td>
</tr>
</table>
<p>source: <a href="http://www.computerhope.com/unix/urm.htm" target="_blank">http://www.computerhope.com/unix/urm.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://music.dreamvib.com/computer/softwares/linux-unix-rm-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tar command</title>
		<link>http://music.dreamvib.com/uncategorized/tar-command/</link>
		<comments>http://music.dreamvib.com/uncategorized/tar-command/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 15:28:57 +0000</pubDate>
		<dc:creator>dreamvib</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://blog.dreamvib.com/?p=5</guid>
		<description><![CDATA[About tarCreate tape archives and add or extract files.
Syntax
tar c  [ bBeEfFhiklnopPqvwX  [ 0-7 ]  ]  [ block ]   [               tarfile  ]   [ exclude-file ]  {-I include-file  &#124; -C directory [...]]]></description>
			<content:encoded><![CDATA[<p>About tarCreate tape archives and add or extract files.</p>
<p class="nb"><a title="02" name="02"></a>Syntax</p>
<p>tar c  [ bBeEfFhiklnopPqvwX  [ 0-7 ]  ]  [ block ]   [               tarfile  ]   [ exclude-file ]  {-I include-file  | -C directory | file  | file }</p>
<p>tar r   [  bBeEfFhiklnqvw   [  0-7  ]   ]   [  block  ]   {-I include-file  | -C directory  | file  | file }</p>
<p>tar t  [ BefFhiklnqvX  [ 0-7 ]  ]  [ tarfile ]   [               exclude-file ]  {-I include-file  | file }  &#8230;</p>
<p>tar u  [ bBeEfFhiklnqvw  [ 0-7 ]  ]  [ block ]  [ tarfile  ]               file &#8230;</p>
<p>tar x  [ BefFhiklmnopqvwX  [  0-7  ]   ]   [  tarfile  ]   [               exclude-file ]  [ file ... ]</p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" width="120">c</td>
<td valign="top">Create. Writing begins at  the  beginning  of  the               tarfile, instead of at the end.</td>
</tr>
<tr>
<td valign="top" width="120">r</td>
<td valign="top">Replace. The named file s are written at the end of the tarfile. A file created with extended headers must be updated with extended headers (see E flag under Function Modifiers). A file created without extended headers cannot be modified with extended headers.</td>
</tr>
<tr>
<td valign="top" width="120">t</td>
<td valign="top">Table of Contents. The names of the specified files are listed each time they occur in the tar file. If no file argument is given, the names of all files in the tarfile are listed. With the v<br />
function modifier, additional information for  the               specified files is displayed.</td>
</tr>
<tr>
<td valign="top" width="120">u</td>
<td valign="top">Update. The named file s are written at the end of the tarfile if they are not already in the tar file, or if they have been modified since last written to that tarfile. An update can be rather slow. A tarfile created on a 5.x system cannot be updated on a 4.x system. A file created with extended headers must be updated with extended headers (see E flag under Function Modifiers). A file created without extended headers cannot be modified with extended headers.</td>
</tr>
<tr>
<td valign="top" width="120">x</td>
<td valign="top">Extract or restore. The named file s are extracted from the tarfile and written to the directory specified in the tarfile, relative to the current directory. Use the relative path names of files and directories to be extracted. If a named file matches a directory whose contents has been writ ten to the tarfile, this directory is recursively extracted. The owner, modification time, and mode are restored (if possible); otherwise, to restore owner, you must be the super-user. Character special and block-special devices (created by mknod(1M)) can only be extracted by the super user. If no file argument is given, the entire content of the tarfile is extracted. If the tar- file contains several files with the same name, each file is written to the appropriate directory, overwriting the previous one. Filename substitu tion wildcards cannot be used for extracting files from the archive; rather, use a command of the form:tar xvf&#8230; /dev/rmt/0 `tar tf&#8230; /dev/rmt/0 | grep &#8216;pattern&#8217; `When extracting tapes created with the r or u functions, directory modification times may not be set correctly. These same functions cannot be used with many tape drives due to tape drive limitations such as the absence of backspace or append capabilities.</p>
<p>When using the r, u, or x functions or the X function modifier, the named files must match exactly the corresponding files in the tarfile. For example, to extract ./thisfile, you must specify ./thisfile, and not thisfile. The t function displays how each file was archived.</td>
</tr>
</table>
<p><strong>Function Modifiers</strong><br />
The characters below may be used  in  conjunction  with  the letter that selects the desired function.</p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" width="120">b</td>
<td valign="top">Blocking Factor. Use when reading or writing to raw magnetic archives (see f below). The block argument specifies the number of 512-byte tape blocks to be included in each read or write operation performed on the tarfile. The minimum is 1, the default is 20. The maximum value is a function of the amount of memory available and the blocking requirements of the specific tape device involved  (see mtio(7I) for details.) The maximum cannot exceed INT_MAX/512 (4194303).When a tape archive is being read, its actual blocking factor will be automatically detected, provided that it is less than or equal to the nominal blocking factor (the value of the block argument, or the default value if the b modifier is not specified). If the actual blocking factor is greater than the nominal blocking factor, a read error will result. See Example 5 in Examples.</td>
</tr>
<tr>
<td valign="top" width="120">B</td>
<td valign="top">Block. Force tar to perform multiple reads (if necessary) to read exactly enough bytes to fill a block. This function modifier enables tar to work across the Ethernet, since pipes and sockets return partial blocks even when more data is coming. When reading from standard input, &#8216;-&#8217;, this function modifier is selected by default to ensure that tar can recover from short reads.</td>
</tr>
<tr>
<td valign="top" width="120">e</td>
<td valign="top">Error. Exit immediately with a positive exit status if any unexpected errors occur. The SYSV3 environment variable overrides the default behavior. (See ENVIRONMENT section below.)</td>
</tr>
<tr>
<td valign="top" width="120">E</td>
<td valign="top">Write a tarfile with extended headers. (Used with c, r, or u options; ignored with t or x options.) When a tarfile is written with extended headers, the modification time is maintained with a granularity of microseconds rather than seconds. In addition, filenames no longer than PATH_MAX characters that could not be archived without E, and file sizes greater than 8GB, are supported. The E flag is required whenever the larger files and/or files with longer names, or whose UID/GID exceed 2097151, are to be archived, or if time granularity of microseconds is desired.</td>
</tr>
<tr>
<td valign="top" width="120">f</td>
<td valign="top">File. Use the tarfile argument as the name of  the               tarfile.  If  f  is specified, /etc/default/tar is<br />
not searched. If f is omitted, tar will use the device indicated by the TAPE environment variable, if set; otherwise, it will use the default values defined in /etc/default/tar. If the name of the tarfile is &#8216;-&#8217;, tar writes to the standard output or reads from the standard input, whichever is appropriate. tar can be used as the head or tail of a pipeline. tar can also be used to move hierarchies with the command:example% cd fromdir; tar cf &#8211; .| (cd todir; tar xfBp -)</td>
</tr>
<tr>
<td valign="top" width="120">F</td>
<td valign="top">With one F argument, tar excludes all directories named SCCS and RCS from the tarfile. With two arguments, FF, tar excludes all directories named SCCS and RCS, all files with .o as their suffix, and all files named errs, core, and a.out. The SYSV3 environment variable overrides the default behavior. (See ENVIRONMENT section below.)</td>
</tr>
<tr>
<td valign="top" width="120">h</td>
<td valign="top">Follow symbolic links as if they were normal files               or  directories.  Normally,  tar   does not follow                     symbolic links.</td>
</tr>
<tr>
<td valign="top" width="120">i</td>
<td valign="top">Ignore directory checksum errors.</td>
</tr>
<tr>
<td valign="top" width="120">-j, &#8211;bzip2</td>
<td valign="top">filter archive through bzip2,                    use to decompress .bz2 files. WARNING: some previous versions                    of tar used option -I to filter through bzip2. When writing                    scripts, use &#8211;bzip2 instead of -j so that both older and                    newer tar versions will work.</td>
</tr>
<tr>
<td valign="top" width="120">k size</td>
<td valign="top">Requires tar to use the size argument as the size of an archive in kilobytes. This is useful when the archive is intended for a fixed size device such as floppy disks. Large files are then split across volumes if they do not fit in the specified size.</td>
</tr>
<tr>
<td valign="top" width="120">l</td>
<td valign="top">Link. Output error message if unable to resolve all links to the files being archived. If l is not specified, no error messages are printed.</td>
</tr>
<tr>
<td valign="top" width="120">m</td>
<td valign="top">Modify. The modification time of the file  is  the               time  of  extraction.  This  function  modifier is<br />
valid only with the x function.</td>
</tr>
<tr>
<td valign="top" width="120">n</td>
<td valign="top">The file being read is a non-tape device.  Reading               of  the  archive is faster since tar  can randomly                     seek around the archive.</td>
</tr>
<tr>
<td valign="top" width="120">o</td>
<td valign="top">Ownership. Assign to extracted files the user and group identifiers of the user running the program, rather than those on tarfile. This is the default behavior for users other than root. If the o function modifier is not set and the user is root, the extracted files will take on the group and user identifiers of the files on tarfile (see <a href="http://www.computerhope.com/unix/uchown.htm"><strong>chown</strong></a>               for  more information). The o function modifier is               only valid with the x function.</td>
</tr>
<tr>
<td valign="top" width="120">p</td>
<td valign="top">Restore the named files to their  original  modes,               and  ACLs  if  applicable,  ignoring  the  present                     <strong><a href="http://www.computerhope.com/unix/uumask.htm">umask</a></strong>. This is the default behavior if invoked as super-user with the x function letter specified. If super-user, SETUID and sticky information are also extracted, and files are restored with their original owners and permissions, rather than owned by root. When this function modifier is used with the c function, ACLs are created in the tarfile along with other information. Errors will occur when a tarfile with ACLs is extracted by<br />
previous versions of tar .</td>
</tr>
<tr>
<td valign="top" width="120">P</td>
<td valign="top">Suppress the addition of a trailing &#8220;/&#8221; on                     directory entries in the archive.</td>
</tr>
<tr>
<td valign="top" width="120">q</td>
<td valign="top">Stop after extracting the first occurrence of  the               named  file.  tar   will normally continue reading                     the archive after finding an occurrence of a file.</td>
</tr>
<tr>
<td valign="top" width="120">v</td>
<td valign="top">Verbose. Output the name of each file preceded  by               the  function  letter. With the t function, v                     provides additional  information  about  the  tarfile entries. The listing is similar to the format                     produced by the -l option of the <strong><a href="http://www.computerhope.com/unix/uls.htm">ls</a></strong> command.</td>
</tr>
<tr>
<td valign="top" width="120">w</td>
<td valign="top">What. Output the action to be taken and the name of the file, then await the user&#8217;s confirmation. If the response is affirmative, the action is performed; otherwise, the action is not performed. This function modifier cannot be used with the t function.</td>
</tr>
<tr>
<td valign="top" width="120">X</td>
<td valign="top">Exclude. Use the exclude-file argument as a file containing a list of relative path names for files (or directories) to be excluded from the tarfile when using the functions c, x, or t. Be careful of trailing white spaces. Also beware of leading white spaces, since, for each line in the excluded file, the entire line (apart from the newline) will be used to match against the initial string of files to exclude. Multiple X arguments may be used, with one exclude-file per argument. In the case where included files (see -I include-file option) are also specified, the excluded files take precedence over all included files. If a file is specified in both the exclude-file and the include-file (or on the command line), it will be excluded.</td>
</tr>
<tr>
<td valign="top" width="120">[0-7]</td>
<td valign="top">Select an alternative drive on which the tape is mounted. The default entries are specified in /etc/default/tar. If no digit or f function modifier is specified, the entry in /etc/default/tar with digit &#8220;0&#8243; is the default.</td>
</tr>
<tr>
<td valign="top" width="120">-I include-file</td>
<td valign="top">Opens include-file containing a list of files, one per line, and treats it as if each file appeared separately on the command line. Be careful of trailing white spaces. Also beware of leading white spaces, since, for each line in the included file, the entire line (apart from the newline) will be used to match against the initial string of files to include. In the case where excluded files (see X function modifier) are also specified, they take precedence over all included files. If a file is specified in both the exclude-file and the include-file (or on the command line), it will be excluded.</td>
</tr>
</table>
<p><strong>Remainder Syntax</strong></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" width="120">-C directory file</td>
<td valign="top">Performs a chdir (see cd(1)) operation on directory and performs the c (create) or r (replace) operation on file . Use short relative path names for file . If file is `.&#8217;, archive all files in directory. This option enables archiving files from multiple directories not related by a close common parent.</td>
</tr>
<tr>
<td valign="top" width="120">file</td>
<td valign="top">A path name of a regular file or directory to be archived (when the c, r or u functions are specified), extracted (x) or listed (t). When file is the path name of a directory, the action applies to all of the files and (recursively) subdirectories of that directory. When a file is archived, and the E flag (see Function Modifiers) is not specified, the filename cannot exceed 256 characters. In addition, it must be possible to split the name between parent directory names so that the prefix is no longer than 155 characters and the name is no longer than 100 characters. If E is specified, a name of up to PATH_MAX characters may be specified.For example, a file whose basename is longer than 100 characters could not be archived without using the E flag. A file whose directory portion is 200 characters and whose basename is 50 characters could be archived (without using E) if a slash appears in the directory name somewhere in character positions 151-156.</td>
</tr>
</table>
<p class="nb"><a title="03" name="03"></a>Examples</p>
<p><strong>Note:</strong> A &#8220;.tar&#8221; file is not a               compressed files, it is actually a collection of files within a               single file uncompressed. If the file is a .tar.gz (&#8221;<a href="http://www.computerhope.com/jargon/t/tarball.htm">tarball</a>&#8220;)               or &#8220;.tgz&#8221; file it is a collection of files that is               compressed. If you are looking to compress a file you would create               the tar file then <a href="http://www.computerhope.com/unix/gzip.htm">gzip</a> the file.</p>
<p><strong>Creating a tar file:</strong></p>
<blockquote><p><strong>tar -cvvf file.tar myfile.tx</strong>t</p>
<p>In the above example the system would create a                 tar named file.tar in the directory you currently are in. <a href="http://www.computerhope.com/jargon/w/wildcard.htm">Wildcards</a>                 could also be used in this command, for example: tar -cvvf                 file.tar *.txt would compress all txt files in the current                 directory.</p>
<p><strong>tar -cvvf home.tar home/</strong></p>
<p>In the above example command the system would                 create a tar file named home.tar in the directory you currently                 are in of the home directory.</p></blockquote>
<p><strong>Extracting the files from a tar file:</strong></p>
<blockquote><p><strong>tar -xvvf myfile.tar</strong></p>
<p>In the above example command the system would                 uncompress (untar) the myfile.tar file in the current directory.</p>
<p><strong>tar -xvvzf myfile.tar.gz</strong></p>
<p>In the above example command the system would                 uncompress (untar) the myfile.tar.gz file in the current directory.</p>
<p><em>Note: There is no &#8220;untar&#8221; linux /               unix command.</em></p></blockquote>
<p><strong>Creating a tarred file that is compressed with                bzip</strong></p>
<blockquote><p><strong>tar -cjvf test.tbz home/</strong></p>
<p>Adding the j option to the tar command enables tar                to compress files and/or directories using bzip. In the above                example the home directory and all its subdirectories are added to                the compressed test.tbz file.</p>
<p align="left">source: <a href="http://www.computerhope.com/unix/utar.htm" target="_blank">http://www.computerhope.com/unix/utar.htm</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://music.dreamvib.com/uncategorized/tar-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
