<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Chapter 7. Client and Utility Programs</title><link rel="stylesheet" href="mysql-html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="MySQL 5.0 Reference Manual"><link rel="up" href="index.html" title="MySQL 5.0 Reference Manual"><link rel="prev" href="optimization.html" title="Chapter 6. Optimization"><link rel="next" href="language-structure.html" title="Chapter 8. Language Structure"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 7. Client and Utility Programs</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="optimization.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="language-structure.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="client-utility-programs"></a>Chapter 7. Client and Utility Programs</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="client-utility-programs.html#client-utility-overview">7.1. Overview of Client and Utility Programs</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#innochecksum">7.2. <span><strong class="command">innochecksum</strong></span> — Offline InnoDB File Checksum Utility</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisam-ftdump">7.3. <span><strong class="command">myisam_ftdump</strong></span> — Display Full-Text Index information</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk">7.4. <span><strong class="command">myisamchk</strong></span> — MyISAM Table-Maintenance Utility</a></span></dt><dd><dl><dt><span class="section"><a href="client-utility-programs.html#myisamchk-general-options">7.4.1. <span><strong class="command">myisamchk</strong></span> General Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-check-options">7.4.2. <span><strong class="command">myisamchk</strong></span> Check Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-repair-options">7.4.3. <span><strong class="command">myisamchk</strong></span> Repair Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-other-options">7.4.4. Other <code class="literal">myisamchk</code> Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-memory">7.4.5. <span><strong class="command">myisamchk</strong></span> Memory Usage</a></span></dt></dl></dd><dt><span class="section"><a href="client-utility-programs.html#myisamlog">7.5. <span><strong class="command">myisamlog</strong></span> — Display MyISAM Log File Contents</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisampack">7.6. <span><strong class="command">myisampack</strong></span> — Generate Compressed, Read-Only MyISAM Tables</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql">7.7. <span><strong class="command">mysql</strong></span> — The MySQL Command-Line Tool</a></span></dt><dd><dl><dt><span class="section"><a href="client-utility-programs.html#mysql-command-options">7.7.1. <span><strong class="command">mysql</strong></span> Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-commands">7.7.2. <span><strong class="command">mysql</strong></span> Commands</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-server-side-help">7.7.3. <span><strong class="command">mysql</strong></span> Server-Side Help</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#batch-commands">7.7.4. Executing SQL Statements from a Text File</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-tips">7.7.5. <span><strong class="command">mysql</strong></span> Tips</a></span></dt></dl></dd><dt><span class="section"><a href="client-utility-programs.html#mysqlaccess">7.8. <span><strong class="command">mysqlaccess</strong></span> — Client for Checking Access Privileges</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqladmin">7.9. <span><strong class="command">mysqladmin</strong></span> — Client for Administering a MySQL Server</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlbinlog">7.10. <span><strong class="command">mysqlbinlog</strong></span> — Utility for Processing Binary Log Files</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlcheck">7.11. <span><strong class="command">mysqlcheck</strong></span> — A Table Maintenance and Repair Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqldump">7.12. <span><strong class="command">mysqldump</strong></span> — A Database Backup Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlhotcopy">7.13. <span><strong class="command">mysqlhotcopy</strong></span> — A Database Backup Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlimport">7.14. <span><strong class="command">mysqlimport</strong></span> — A Data Import Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlmanagerc">7.15. <span><strong class="command">mysqlmanagerc</strong></span> — Internal Test-Suite Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlmanager-pwgen">7.16. <span><strong class="command">mysqlmanager-pwgen</strong></span> — Internal Test-Suite Program</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysqlshow">7.17. <span><strong class="command">mysqlshow</strong></span> — Display Database, Table, and Column Information</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-convert-table-format">7.18. <span><strong class="command">mysql_convert_table_format</strong></span> — Convert Tables to Use a Given Storage Engine</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-explain-log">7.19. <span><strong class="command">mysql_explain_log</strong></span> — Use EXPLAIN on Statements in Query Log</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-find-rows">7.20. <span><strong class="command">mysql_find_rows</strong></span> — Extract SQL Statements from Files</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-fix-extensions">7.21. <span><strong class="command">mysql_fix_extensions</strong></span> — Make Table Filename Extensions Lowercase</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-setpermission">7.22. <span><strong class="command">mysql_setpermission</strong></span> — Interactively Set Permissions in Grant Tables</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-tableinfo">7.23. <span><strong class="command">mysql_tableinfo</strong></span> — Generate Database Metadata</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-waitpid">7.24. <span><strong class="command">mysql_waitpid</strong></span> — Kill Process and Wait for Its Termination</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-zap">7.25. <span><strong class="command">mysql_zap</strong></span> — Kill Processes That Match a Pattern</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#perror">7.26. <span><strong class="command">perror</strong></span> — Explain Error Codes</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#replace-utility">7.27. <span><strong class="command">replace</strong></span> — A String-Replacement Utility</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#resolveip">7.28. <span><strong class="command">resolveip</strong></span> — Resolve Hostname to IP Address or Vice Versa</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#resolve-stack-dump">7.29. <span><strong class="command">resolve_stack_dump</strong></span> — Resolve Numeric Stack Trace Dump to Symbols</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#programming-utilities">7.30. MySQL Program Development Utilities</a></span></dt><dd><dl><dt><span class="section"><a href="client-utility-programs.html#msql2mysql">7.30.1. <span><strong class="command">msql2mysql</strong></span> — Convert mSQL Programs for Use with MySQL</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-config">7.30.2. <span><strong class="command">mysql_config</strong></span> — Get Compile Options for Compiling Clients</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#my-print-defaults">7.30.3. <span><strong class="command">my_print_defaults</strong></span> — Display Options from Option Files</a></span></dt></dl></dd></dl></div><p> There are many different MySQL client programs that connect to the server to access databases or perform administrative tasks. Other utilities are available as well. These do not establish a client connection with the server but perform MySQL-related operations. </p><p> This chapter provides a brief overview of these programs and then a more detailed description of each one. Each program's description indicates its invocation syntax and the options that it understands. See <a href="using-mysql-programs.html" title="Chapter 4. Using MySQL Programs">Chapter 4, <i>Using MySQL Programs</i></a>, for general information on invoking programs and specifying program options. </p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="client-utility-overview"></a>7.1. Overview of Client and Utility Programs</h2></div></div></div><p> The following list briefly describes the MySQL client programs and utilities: </p><a class="indexterm" name="id2696311"></a><a class="indexterm" name="id2696320"></a><a class="indexterm" name="id2696332"></a><a class="indexterm" name="id2696341"></a><div class="itemizedlist"><ul type="disc"><li><p> <a class="indexterm" name="id2696360"></a> <span><strong class="command">innochecksum</strong></span> </p><p> An offline <code class="literal">InnoDB</code> offline file checksum utility. See <a href="client-utility-programs.html#innochecksum" title="7.2. innochecksum — Offline InnoDB File Checksum Utility">Section 7.2, “<span><strong class="command">innochecksum</strong></span> — Offline InnoDB File Checksum Utility”</a>. </p></li><li><p> <a class="indexterm" name="id2696397"></a> <span><strong class="command">myisam_ftdump</strong></span> </p><p> A utility that displays information about full-text indexes in <code class="literal">MyISAM</code> tables. See <a href="client-utility-programs.html#myisam-ftdump" title="7.3. myisam_ftdump — Display Full-Text Index information">Section 7.3, “<span><strong class="command">myisam_ftdump</strong></span> — Display Full-Text Index information”</a>. </p></li><li><p> <a class="indexterm" name="id2696434"></a> <span><strong class="command">myisamchk</strong></span> </p><p> A utility to describe, check, optimize, and repair <code class="literal">MyISAM</code> tables. See <a href="client-utility-programs.html#myisamchk" title="7.4. myisamchk — MyISAM Table-Maintenance Utility">Section 7.4, “<span><strong class="command">myisamchk</strong></span> — MyISAM Table-Maintenance Utility”</a>. </p></li><li><p> <a class="indexterm" name="id2696470"></a> <a class="indexterm" name="id2696479"></a> <span><strong class="command">myisamlog</strong></span>, <span><strong class="command">isamlog</strong></span> </p><p> A utility that processes the contents of a <code class="literal">MyISAM</code> log file. See <a href="client-utility-programs.html#myisamlog" title="7.5. myisamlog — Display MyISAM Log File Contents">Section 7.5, “<span><strong class="command">myisamlog</strong></span> — Display MyISAM Log File Contents”</a>. </p></li><li><p> <a class="indexterm" name="id2696522"></a> <span><strong class="command">myisampack</strong></span> </p><p> A utility that compresses <code class="literal">MyISAM</code> tables to produce smaller read-only tables. See <a href="client-utility-programs.html#myisampack" title="7.6. myisampack — Generate Compressed, Read-Only MyISAM Tables">Section 7.6, “<span><strong class="command">myisampack</strong></span> — Generate Compressed, Read-Only MyISAM Tables”</a>. </p></li><li><p> <a class="indexterm" name="id2696558"></a> <span><strong class="command">mysql</strong></span> </p><p> The command-line tool for interactively entering SQL statements or executing them from a file in batch mode. See <a href="client-utility-programs.html#mysql" title="7.7. mysql — The MySQL Command-Line Tool">Section 7.7, “<span><strong class="command">mysql</strong></span> — The MySQL Command-Line Tool”</a>. </p></li><li><p> <a class="indexterm" name="id2696590"></a> <span><strong class="command">mysqlaccess</strong></span> </p><p> A script that checks the access privileges for a hostname, username, and database combination. See <a href="client-utility-programs.html#mysqlaccess" title="7.8. mysqlaccess — Client for Checking Access Privileges">Section 7.8, “<span><strong class="command">mysqlaccess</strong></span> — Client for Checking Access Privileges”</a>. </p></li><li><p> <a class="indexterm" name="id2696621"></a> <span><strong class="command">mysqladmin</strong></span> </p><p> A client that performs administrative operations, such as creating or dropping databases, reloading the grant tables, flushing tables to disk, and reopening log files. <span><strong class="command">mysqladmin</strong></span> can also be used to retrieve version, process, and status information from the server. See <a href="client-utility-programs.html#mysqladmin" title="7.9. mysqladmin — Client for Administering a MySQL Server">Section 7.9, “<span><strong class="command">mysqladmin</strong></span> — Client for Administering a MySQL Server”</a>. </p></li><li><p> <a class="indexterm" name="id2696661"></a> <span><strong class="command">mysqlbinlog</strong></span> </p><p> A utility for reading statements from a binary log. The log of executed statements contained in the binary log files can be used to help recover from a crash. See <a href="client-utility-programs.html#mysqlbinlog" title="7.10. mysqlbinlog — Utility for Processing Binary Log Files">Section 7.10, “<span><strong class="command">mysqlbinlog</strong></span> — Utility for Processing Binary Log Files”</a>. </p></li><li><p> <a class="indexterm" name="id2696694"></a> <span><strong class="command">mysqlcheck</strong></span> </p><p> A table-maintenance client that checks, repairs, analyzes, and optimizes tables. See <a href="client-utility-programs.html#mysqlcheck" title="7.11. mysqlcheck — A Table Maintenance and Repair Program">Section 7.11, “<span><strong class="command">mysqlcheck</strong></span> — A Table Maintenance and Repair Program”</a>. </p></li><li><p> <a class="indexterm" name="id2696725"></a> <span><strong class="command">mysqldump</strong></span> </p><p> A client that dumps a MySQL database into a file as SQL, text, or XML. See <a href="client-utility-programs.html#mysqldump" title="7.12. mysqldump — A Database Backup Program">Section 7.12, “<span><strong class="command">mysqldump</strong></span> — A Database Backup Program”</a>. </p></li><li><p> <a class="indexterm" name="id2696755"></a> <span><strong class="command">mysqlhotcopy</strong></span> </p><p> A utility that quickly makes backups of <code class="literal">MyISAM</code> tables while the server is running. See <a href="client-utility-programs.html#mysqlhotcopy" title="7.13. mysqlhotcopy — A Database Backup Program">Section 7.13, “<span><strong class="command">mysqlhotcopy</strong></span> — A Database Backup Program”</a>. </p></li><li><p> <a class="indexterm" name="id2696792"></a> <span><strong class="command">mysqlimport</strong></span> </p><p> A client that imports text files into their respective tables using <code class="literal">LOAD DATA INFILE</code>. See <a href="client-utility-programs.html#mysqlimport" title="7.14. mysqlimport — A Data Import Program">Section 7.14, “<span><strong class="command">mysqlimport</strong></span> — A Data Import Program”</a>. </p></li><li><p> <a class="indexterm" name="id2696829"></a> <span><strong class="command">mysqlshow</strong></span> </p><p> A client that displays information about databases, tables, columns, and indexes. See <a href="client-utility-programs.html#mysqlshow" title="7.17. mysqlshow — Display Database, Table, and Column Information">Section 7.17, “<span><strong class="command">mysqlshow</strong></span> — Display Database, Table, and Column Information”</a>. </p></li><li><p> <a class="indexterm" name="id2696860"></a> <span><strong class="command">mysql_convert_table_format</strong></span> </p><p> A utility that converts tables in a database to use a given storage engine. See <a href="client-utility-programs.html#mysql-convert-table-format" title="7.18. mysql_convert_table_format — Convert Tables to Use a Given Storage Engine">Section 7.18, “<span><strong class="command">mysql_convert_table_format</strong></span> — Convert Tables to Use a Given Storage Engine”</a>. </p></li><li><p> <a class="indexterm" name="id2696892"></a> <span><strong class="command">mysql_explain_log</strong></span> </p><p> A utility that analyzes queries in the MySQL query log using <code class="literal">EXPLAIN</code> See <a href="client-utility-programs.html#mysql-explain-log" title="7.19. mysql_explain_log — Use EXPLAIN on Statements in Query Log">Section 7.19, “<span><strong class="command">mysql_explain_log</strong></span> — Use EXPLAIN on Statements in Query Log”</a>. </p></li><li><p> <a class="indexterm" name="id2696929"></a> <span><strong class="command">mysql_find_rows</strong></span> </p><p> A utility that reads files containing SQL statements (such as update logs) and extracts statements that match a given regular expression. See <a href="client-utility-programs.html#mysql-find-rows" title="7.20. mysql_find_rows — Extract SQL Statements from Files">Section 7.20, “<span><strong class="command">mysql_find_rows</strong></span> — Extract SQL Statements from Files”</a>. </p></li><li><p> <a class="indexterm" name="id2696961"></a> <span><strong class="command">mysql_fix_extensions</strong></span> </p><p> A utility that converts the extensions for <code class="literal">MyISAM</code> table files to lowercase. This can be useful after transferring the files from a system with case-insensitive filenames to a system with case-sensitive filenames. See <a href="client-utility-programs.html#mysql-fix-extensions" title="7.21. mysql_fix_extensions — Make Table Filename Extensions Lowercase">Section 7.21, “<span><strong class="command">mysql_fix_extensions</strong></span> — Make Table Filename Extensions Lowercase”</a>. </p></li><li><p> <a class="indexterm" name="id2697001"></a> <span><strong class="command">mysql_setpermission</strong></span> </p><p> A utility for interactively setting permissions in the MySQL grant tables. See <a href="client-utility-programs.html#mysql-setpermission" title="7.22. mysql_setpermission — Interactively Set Permissions in Grant Tables">Section 7.22, “<span><strong class="command">mysql_setpermission</strong></span> — Interactively Set Permissions in Grant Tables”</a>. </p></li><li><p> <a class="indexterm" name="id2697032"></a> <span><strong class="command">mysql_tableinfo</strong></span> </p><p> A utility that generates database metadata. <a href="client-utility-programs.html#mysql-tableinfo" title="7.23. mysql_tableinfo — Generate Database Metadata">Section 7.23, “<span><strong class="command">mysql_tableinfo</strong></span> — Generate Database Metadata”</a>. </p></li><li><p> <a class="indexterm" name="id2697063"></a> <span><strong class="command">mysql_waitpid</strong></span> </p><p> A utility that kills the process with a given process ID. See <a href="client-utility-programs.html#mysql-waitpid" title="7.24. mysql_waitpid — Kill Process and Wait for Its Termination">Section 7.24, “<span><strong class="command">mysql_waitpid</strong></span> — Kill Process and Wait for Its Termination”</a>. </p></li><li><p> <a class="indexterm" name="id2697094"></a> <span><strong class="command">mysql_zap</strong></span> </p><p> A utility that kills processes that match a pattern. See <a href="client-utility-programs.html#mysql-zap" title="7.25. mysql_zap — Kill Processes That Match a Pattern">Section 7.25, “<span><strong class="command">mysql_zap</strong></span> — Kill Processes That Match a Pattern”</a>. </p></li><li><p> <a class="indexterm" name="id2697124"></a> <span><strong class="command">perror</strong></span> </p><p> A utility that displays the meaning of system or MySQL error codes. See <a href="client-utility-programs.html#perror" title="7.26. perror — Explain Error Codes">Section 7.26, “<span><strong class="command">perror</strong></span> — Explain Error Codes”</a>. </p></li><li><p> <a class="indexterm" name="id2697155"></a> <span><strong class="command">replace</strong></span> </p><p> A utility program that performs string replacement in the input text. See <a href="client-utility-programs.html#replace-utility" title="7.27. replace — A String-Replacement Utility">Section 7.27, “<span><strong class="command">replace</strong></span> — A String-Replacement Utility”</a>. </p></li><li><p> <a class="indexterm" name="id2697186"></a> <span><strong class="command">resolveip</strong></span> </p><p> A utility program that resolves a hostname to an IP address or vice versa. See <a href="client-utility-programs.html#resolveip" title="7.28. resolveip — Resolve Hostname to IP Address or Vice Versa">Section 7.28, “<span><strong class="command">resolveip</strong></span> — Resolve Hostname to IP Address or Vice Versa”</a>. </p></li><li><p> <a class="indexterm" name="id2697216"></a> <span><strong class="command">resolve_stack_dump</strong></span> </p><p> A utility program that resolves a numeric stack trace dump to symbols. See <a href="client-utility-programs.html#resolve-stack-dump" title="7.29. resolve_stack_dump — Resolve Numeric Stack Trace Dump to Symbols">Section 7.29, “<span><strong class="command">resolve_stack_dump</strong></span> — Resolve Numeric Stack Trace Dump to Symbols”</a>. </p></li></ul></div><p> MySQL AB also provides a number of GUI tools for administering and otherwise working with MySQL servers. For basic information about these, see <a href="using-mysql-programs.html" title="Chapter 4. Using MySQL Programs">Chapter 4, <i>Using MySQL Programs</i></a>. </p><p> Each MySQL program takes many different options. Most programs provide a <code class="option">--help</code> option that you can use to get a full description of the program's different options. For example, try <span><strong class="command">mysql --help</strong></span>. </p><a class="indexterm" name="id2697272"></a><p> MySQL client programs that communicate with the server using the MySQL client/server library use the following environment variables: </p><a class="indexterm" name="id2697287"></a><a class="indexterm" name="id2697296"></a><a class="indexterm" name="id2697309"></a><a class="indexterm" name="id2697319"></a><a class="indexterm" name="id2697331"></a><a class="indexterm" name="id2697341"></a><a class="indexterm" name="id2697353"></a><a class="indexterm" name="id2697363"></a><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">MYSQL_UNIX_PORT</code></td><td>The default Unix socket file; used for connections to <code class="literal">localhost</code></td></tr><tr><td><code class="literal">MYSQL_TCP_PORT</code></td><td>The default port number; used for TCP/IP connections</td></tr><tr><td><code class="literal">MYSQL_PWD</code></td><td>The default password</td></tr><tr><td><code class="literal">MYSQL_DEBUG</code></td><td>Debug trace options when debugging</td></tr><tr><td><code class="literal">TMPDIR</code></td><td>The directory where temporary tables and files are created</td></tr></tbody></table></div><p> Use of <code class="literal">MYSQL_PWD</code> is insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p><p> You can override the default option values or values specified in environment variables for all standard programs by specifying options in an option file or on the command line. See <a href="using-mysql-programs.html#program-options" title="4.3. Specifying Program Options">Section 4.3, “Specifying Program Options”</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="innochecksum"></a>7.2. <span><strong class="command">innochecksum</strong></span> — Offline InnoDB File Checksum Utility</h2></div></div></div><p> <span><strong class="command">innochecksum</strong></span> prints checksums for <code class="literal">InnoDB</code> files. </p><p> Invoke <span><strong class="command">innochecksum</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>innochecksum [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>file_name</code></em></code></strong> </pre><p> <span><strong class="command">innodchecksum</strong></span> understands the options described in the following list. For options that refer to page numbers, the numbers are zero-based. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_innochecksum_count"></a> <code class="option">-c</code> </p><p> Print a count of the number of pages in the file. </p></li><li><p><a name="option_innochecksum_debug"></a> <code class="option">-d</code> </p><p> Debug mode; prints checksums for each page. </p></li><li><p><a name="option_innochecksum_end"></a> <code class="option">-e <em class="replaceable"><code>num</code></em></code> </p><p> End at this page number. </p></li><li><p><a name="option_innochecksum_page"></a> <code class="option">-p <em class="replaceable"><code>num</code></em></code> </p><p> Check only this page number. </p></li><li><p><a name="option_innochecksum_start"></a> <code class="option">-s <em class="replaceable"><code>num</code></em></code> </p><p> Start at this page number. </p></li><li><p><a name="option_innochecksum_verbose"></a> <code class="option">-v</code> </p><p> Verbose mode; print a progress indicator every five seconds. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="myisam-ftdump"></a>7.3. <span><strong class="command">myisam_ftdump</strong></span> — Display Full-Text Index information</h2></div></div></div><p> <span><strong class="command">myisam_ftdump</strong></span> displays information about <code class="literal">FULLTEXT</code> indexes in <code class="literal">MyISAM</code> tables. It reads the <code class="literal">MyISAM</code> index file directly, so it must be run on the server host where the table is located </p><p> Invoke <span><strong class="command">myisam_ftdump</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisam_ftdump [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>tbl_name</code></em> <em class="replaceable"><code>index_num</code></em></code></strong> </pre><p> The <em class="replaceable"><code>tbl_name</code></em> argument should be the name of a <code class="literal">MyISAM</code> table. You can also specify a table by naming its index file (the file with the <code class="filename">.MYI</code> suffix). If you do not invoke <span><strong class="command">myisam_ftdump</strong></span> in the directory where the table files are located, the table or index file name must be preceded by the pathname to the table's database directory. Index numbers begin with 0. </p><p> Example: Suppose that the <code class="literal">test</code> database contains a table named <code class="literal">mytexttablel</code> that has the following definition: </p><pre class="programlisting">CREATE TABLE mytexttable ( id INT NOT NULL, txt TEXT NOT NULL, PRIMARY KEY (id), FULLTEXT (txt) ); </pre><p> The index on <code class="literal">id</code> is index 0 and the <code class="literal">FULLTEXT</code> index on <code class="literal">txt</code> is index 1. If your working directory is the <code class="literal">test</code> database directory, invoke <span><strong class="command">myisam_ftdump</strong></span> as follows: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisam_ftdump mytexttable 1</code></strong> </pre><p> If the pathname to the <code class="literal">test</code> database directory is <code class="filename">/usr/local/mysql/data/test</code>, you can also specify the table name argument using that pathname. This is useful if you do not invoke <span><strong class="command">myisam_ftdump</strong></span> in the database directory: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisam_ftdump /usr/local/mysql/data/test/mytexttable 1</code></strong> </pre><p> <span><strong class="command">myisam_ftdump</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisam_ftdump_help"></a> <a class="indexterm" name="id2697913"></a> <a class="indexterm" name="id2697926"></a> <code class="option">--help</code>, <code class="option">-h</code> <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_myisam_ftdump_count"></a> <a class="indexterm" name="id2697962"></a> <a class="indexterm" name="id2697974"></a> <code class="option">--count</code>, <code class="option">-c</code> </p><p> Calculate per-word statistics (counts and global weights). </p></li><li><p><a name="option_myisam_ftdump_dump"></a> <a class="indexterm" name="id2698007"></a> <a class="indexterm" name="id2698020"></a> <code class="option">--dump</code>, <code class="option">-d</code> </p><p> Dump the index, including data offsets and word weights. </p></li><li><p><a name="option_myisam_ftdump_length"></a> <a class="indexterm" name="id2698053"></a> <a class="indexterm" name="id2698065"></a> <code class="option">--length</code>, <code class="option">-l</code> </p><p> Report the length distribution. </p></li><li><p><a name="option_myisam_ftdump_stats"></a> <a class="indexterm" name="id2698098"></a> <a class="indexterm" name="id2698111"></a> <code class="option">--stats</code>, <code class="option">-s</code> </p><p> Report global index statistics. This is the default operation if no other operation is specified. </p></li><li><p><a name="option_myisam_ftdump_verbose"></a> <a class="indexterm" name="id2698145"></a> <a class="indexterm" name="id2698157"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more output about what the program does. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="myisamchk"></a>7.4. <span><strong class="command">myisamchk</strong></span> — MyISAM Table-Maintenance Utility</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="client-utility-programs.html#myisamchk-general-options">7.4.1. <span><strong class="command">myisamchk</strong></span> General Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-check-options">7.4.2. <span><strong class="command">myisamchk</strong></span> Check Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-repair-options">7.4.3. <span><strong class="command">myisamchk</strong></span> Repair Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-other-options">7.4.4. Other <code class="literal">myisamchk</code> Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#myisamchk-memory">7.4.5. <span><strong class="command">myisamchk</strong></span> Memory Usage</a></span></dt></dl></div><p> The <span><strong class="command">myisamchk</strong></span> utility gets information about your database tables or checks, repairs, or optimizes them. <span><strong class="command">myisamchk</strong></span> works with <code class="literal">MyISAM</code> tables (tables that have <code class="filename">.MYD</code> and <code class="filename">.MYI</code> files for storing data and indexes). </p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p> It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to filesystem errors. </p></div><p> Invoke <span><strong class="command">myisamchk</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>tbl_name</code></em> ...</code></strong> </pre><p> The <em class="replaceable"><code>options</code></em> specify what you want <span><strong class="command">myisamchk</strong></span> to do. They are described in the following sections. You can also get a list of options by invoking <span><strong class="command">myisamchk --help</strong></span>. </p><p> With no options, <span><strong class="command">myisamchk</strong></span> simply checks your table as the default operation. To get more information or to tell <span><strong class="command">myisamchk</strong></span> to take corrective action, specify options as described in the following discussion. </p><p> <em class="replaceable"><code>tbl_name</code></em> is the database table you want to check or repair. If you run <span><strong class="command">myisamchk</strong></span> somewhere other than in the database directory, you must specify the path to the database directory, because <span><strong class="command">myisamchk</strong></span> has no idea where the database is located. In fact, <span><strong class="command">myisamchk</strong></span> doesn't actually care whether the files you are working on are located in a database directory. You can copy the files that correspond to a database table into some other location and perform recovery operations on them there. </p><p> You can name several tables on the <span><strong class="command">myisamchk</strong></span> command line if you wish. You can also specify a table by naming its index file (the file with the <code class="filename">.MYI</code> suffix). This allows you to specify all tables in a directory by using the pattern <code class="filename">*.MYI</code>. For example, if you are in a database directory, you can check all the <code class="literal">MyISAM</code> tables in that directory like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk *.MYI</code></strong> </pre><p> If you are not in the database directory, you can check all the tables there by specifying the path to the directory: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk <em class="replaceable"><code>/path/to/database_dir/</code></em>*.MYI</code></strong> </pre><p> You can even check all tables in all databases by specifying a wildcard with the path to the MySQL data directory: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk <em class="replaceable"><code>/path/to/datadir/*/*</code></em>.MYI</code></strong> </pre><p> The recommended way to quickly check all <code class="literal">MyISAM</code> tables is: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk --silent --fast <em class="replaceable"><code>/path/to/datadir/*/*</code></em>.MYI</code></strong> </pre><p> If you want to check all <code class="literal">MyISAM</code> tables and repair any that are corrupted, you can use the following command: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk --silent --force --fast --update-state \</code></strong> <strong class="userinput"><code>--key_buffer_size=64M --sort_buffer_size=64M \</code></strong> <strong class="userinput"><code>--read_buffer_size=1M --write_buffer_size=1M \</code></strong> <strong class="userinput"><code><em class="replaceable"><code>/path/to/datadir/*/*</code></em>.MYI</code></strong> </pre><p> This command assumes that you have more than 64MB free. For more information about memory allocation with <span><strong class="command">myisamchk</strong></span>, see <a href="client-utility-programs.html#myisamchk-memory" title="7.4.5. myisamchk Memory Usage">Section 7.4.5, “<span><strong class="command">myisamchk</strong></span> Memory Usage”</a>. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on checking and repairing tables, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p> <span class="emphasis"><em>You must ensure that no other program is using the tables while you are running <span><strong class="command">myisamchk</strong></span></em></span>. The most effective means of doing so is to shut down the MySQL server while running <span><strong class="command">myisamchk</strong></span>, or to lock all tables that <span><strong class="command">myisamchk</strong></span> is being used on. </p><p> Otherwise, when you run <span><strong class="command">myisamchk</strong></span>, it may display the following error message: </p><pre class="programlisting">warning: clients are using or haven't closed the table properly </pre><p> This means that you are trying to check a table that has been updated by another program (such as the <span><strong class="command">mysqld</strong></span> server) that hasn't yet closed the file or that has died without closing the file properly, which can sometimes lead to the corruption of one or more <code class="literal">MyISAM</code> tables. </p><p> If <span><strong class="command">mysqld</strong></span> is running, you must force it to flush any table modifications that are still buffered in memory by using <code class="literal">FLUSH TABLES</code>. You should then ensure that no one is using the tables while you are running <span><strong class="command">myisamchk</strong></span> </p><p> However, the easiest way to avoid this problem is to use <code class="literal">CHECK TABLE</code> instead of <span><strong class="command">myisamchk</strong></span> to check tables. See <a href="sql-syntax.html#check-table" title="12.5.2.3. CHECK TABLE Syntax">Section 12.5.2.3, “<code class="literal">CHECK TABLE</code> Syntax”</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="myisamchk-general-options"></a>7.4.1. <span><strong class="command">myisamchk</strong></span> General Options</h3></div></div></div><a class="indexterm" name="id2698678"></a><a class="indexterm" name="id2698690"></a><p> The options described in this section can be used for any type of table maintenance operation performed by <span><strong class="command">myisamchk</strong></span>. The sections following this one describe options that pertain only to specific operations, such as table checking or repairing. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisamchk_help"></a> <a class="indexterm" name="id2698725"></a> <a class="indexterm" name="id2698738"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_myisamchk_debug"></a> <a class="indexterm" name="id2698770"></a> <a class="indexterm" name="id2698783"></a> <code class="option">--debug=<em class="replaceable"><code>debug_options</code></em>, -# <em class="replaceable"><code>debug_options</code></em></code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_myisamchk_silent"></a> <a class="indexterm" name="id2698832"></a> <a class="indexterm" name="id2698845"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Write output only when errors occur. You can use <code class="option">-s</code> twice (<code class="option">-ss</code>) to make <span><strong class="command">myisamchk</strong></span> very silent. </p></li><li><p><a name="option_myisamchk_verbose"></a> <a class="indexterm" name="id2698892"></a> <a class="indexterm" name="id2698904"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. This can be used with <code class="option">-d</code> and <code class="option">-e</code>. Use <code class="option">-v</code> multiple times (<code class="option">-vv</code>, <code class="option">-vvv</code>) for even more output. </p></li><li><p><a name="option_myisamchk_version"></a> <a class="indexterm" name="id2698956"></a> <a class="indexterm" name="id2698969"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li><li><p><a name="option_myisamchk_wait"></a> <a class="indexterm" name="id2699001"></a> <a class="indexterm" name="id2699014"></a> <code class="option">--wait</code>, <code class="option">-w</code> </p><p> Instead of terminating with an error if the table is locked, wait until the table is unlocked before continuing. If you are running <span><strong class="command">mysqld</strong></span> with external locking disabled, the table can be locked only by another <span><strong class="command">myisamchk</strong></span> command. </p></li></ul></div><p> You can also set the following variables by using <code class="option">--<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax: </p><a class="indexterm" name="id2699070"></a><a class="indexterm" name="id2699080"></a><a class="indexterm" name="id2699089"></a><a class="indexterm" name="id2699098"></a><a class="indexterm" name="id2699108"></a><a class="indexterm" name="id2699117"></a><a class="indexterm" name="id2699126"></a><a class="indexterm" name="id2699136"></a><a class="indexterm" name="id2699145"></a><a class="indexterm" name="id2699154"></a><a class="indexterm" name="id2699164"></a><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><span class="bold"><strong>Variable</strong></span></td><td><span class="bold"><strong>Default Value</strong></span></td></tr><tr><td><code class="literal">decode_bits</code></td><td>9</td></tr><tr><td><code class="literal">ft_max_word_len</code></td><td>version-dependent</td></tr><tr><td><code class="literal">ft_min_word_len</code></td><td>4</td></tr><tr><td><code class="literal">ft_stopword_file</code></td><td>built-in list</td></tr><tr><td><code class="literal">key_buffer_size</code></td><td>523264</td></tr><tr><td><code class="literal">myisam_block_size</code></td><td>1024</td></tr><tr><td><code class="literal">read_buffer_size</code></td><td>262136</td></tr><tr><td><code class="literal">sort_buffer_size</code></td><td>2097144</td></tr><tr><td><code class="literal">sort_key_blocks</code></td><td>16</td></tr><tr><td><code class="literal">stats_method</code></td><td>nulls_unequal</td></tr><tr><td><code class="literal">write_buffer_size</code></td><td>262136</td></tr></tbody></table></div><p> It is also possible to set variables by using <code class="option">--set-variable=<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> or <code class="option">-O <em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax. However, this syntax is deprecated as of MySQL 4.0. </p><p> The possible <span><strong class="command">myisamchk</strong></span> variables and their default values can be examined with <span><strong class="command">myisamchk --help</strong></span>: </p><p> <code class="literal">sort_buffer_size</code> is used when the keys are repaired by sorting keys, which is the normal case when you use <code class="option">--recover</code>. </p><p> <code class="literal">key_buffer_size</code> is used when you are checking the table with <code class="option">--extend-check</code> or when the keys are repaired by inserting keys row by row into the table (like when doing normal inserts). Repairing through the key buffer is used in the following cases: </p><div class="itemizedlist"><ul type="disc"><li><p> You use <code class="option">--safe-recover</code>. </p></li><li><p> The temporary files needed to sort the keys would be more than twice as big as when creating the key file directly. This is often the case when you have large key values for <code class="literal">CHAR</code>, <code class="literal">VARCHAR</code>, or <code class="literal">TEXT</code> columns, because the sort operation needs to store the complete key values as it proceeds. If you have lots of temporary space and you can force <span><strong class="command">myisamchk</strong></span> to repair by sorting, you can use the <code class="option">--sort-recover</code> option. </p></li></ul></div><p> Repairing through the key buffer takes much less disk space than using sorting, but is also much slower. </p><p> If you want a faster repair, set the <code class="literal">key_buffer_size</code> and <code class="literal">sort_buffer_size</code> variables to about 25% of your available memory. You can set both variables to large values, because only one of them is used at a time. </p><p> <code class="literal">myisam_block_size</code> is the size used for index blocks. </p><p> <code class="literal">stats_method</code> influences how <code class="literal">NULL</code> values are treated for index statistics collection when the <code class="option">--analyze</code> option is given. It acts like the <code class="literal">myisam_stats_method</code> system variable. For more information, see the description of <code class="literal">myisam_stats_method</code> in <a href="server-administration.html#server-system-variables" title="5.2.3. System Variables">Section 5.2.3, “System Variables”</a>, and <a href="optimization.html#myisam-index-statistics" title="6.4.7. MyISAM Index Statistics Collection">Section 6.4.7, “<code class="literal">MyISAM</code> Index Statistics Collection”</a>. For MySQL 5.0, <code class="literal">stats_method</code> was added in MySQL 5.0.14. For older versions, the statistics collection method is equivalent to <code class="literal">nulls_equal</code>. </p><p> The <code class="literal">ft_min_word_len</code> and <code class="literal">ft_max_word_len</code> variables are available as of MySQL 4.0.0. <code class="literal">ft_stopword_file</code> is available as of MySQL 4.0.19. </p><p> <code class="literal">ft_min_word_len</code> and <code class="literal">ft_max_word_len</code> indicate the minimum and maximum word length for <code class="literal">FULLTEXT</code> indexes. <code class="literal">ft_stopword_file</code> names the stopword file. These need to be set under the following circumstances. </p><p> If you use <span><strong class="command">myisamchk</strong></span> to perform an operation that modifies table indexes (such as repair or analyze), the <code class="literal">FULLTEXT</code> indexes are rebuilt using the default full-text parameter values for minimum and maximum word length and the stopword file unless you specify otherwise. This can result in queries failing. </p><p> The problem occurs because these parameters are known only by the server. They are not stored in <code class="literal">MyISAM</code> index files. To avoid the problem if you have modified the minimum or maximum word length or the stopword file in the server, specify the same <code class="literal">ft_min_word_len</code>, <code class="literal">ft_max_word_len</code>, and <code class="literal">ft_stopword_file</code> values to <span><strong class="command">myisamchk</strong></span> that you use for <span><strong class="command">mysqld</strong></span>. For example, if you have set the minimum word length to 3, you can repair a table with <span><strong class="command">myisamchk</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk --recover --ft_min_word_len=3 <em class="replaceable"><code>tbl_name</code></em>.MYI</code></strong> </pre><p> To ensure that <span><strong class="command">myisamchk</strong></span> and the server use the same values for full-text parameters, you can place each one in both the <code class="literal">[mysqld]</code> and <code class="literal">[myisamchk]</code> sections of an option file: </p><pre class="programlisting">[mysqld] ft_min_word_len=3 [myisamchk] ft_min_word_len=3 </pre><p> An alternative to using <span><strong class="command">myisamchk</strong></span> is to use the <code class="literal">REPAIR TABLE</code>, <code class="literal">ANALYZE TABLE</code>, <code class="literal">OPTIMIZE TABLE</code>, or <code class="literal">ALTER TABLE</code>. These statements are performed by the server, which knows the proper full-text parameter values to use. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="myisamchk-check-options"></a>7.4.2. <span><strong class="command">myisamchk</strong></span> Check Options</h3></div></div></div><a class="indexterm" name="id2699809"></a><a class="indexterm" name="id2699822"></a><p> <span><strong class="command">myisamchk</strong></span> supports the following options for table checking operations: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisamchk_check"></a> <a class="indexterm" name="id2699854"></a> <a class="indexterm" name="id2699866"></a> <code class="option">--check</code>, <code class="option">-c</code> </p><p> Check the table for errors. This is the default operation if you specify no option that selects an operation type explicitly. </p></li><li><p><a name="option_myisamchk_check-only-changed"></a> <a class="indexterm" name="id2699901"></a> <a class="indexterm" name="id2699914"></a> <code class="option">--check-only-changed</code>, <code class="option">-C</code> </p><p> Check only tables that have changed since the last check. </p></li><li><p><a name="option_myisamchk_extend-check"></a> <a class="indexterm" name="id2699947"></a> <a class="indexterm" name="id2699960"></a> <code class="option">--extend-check</code>, <code class="option">-e</code> </p><p> Check the table very thoroughly. This is quite slow if the table has many indexes. This option should only be used in extreme cases. Normally, <span><strong class="command">myisamchk</strong></span> or <span><strong class="command">myisamchk --medium-check</strong></span> should be able to determine whether there are any errors in the table. </p><p> If you are using <code class="option">--extend-check</code> and have plenty of memory, setting the <code class="literal">key_buffer_size</code> variable to a large value helps the repair operation run faster. </p></li><li><p><a name="option_myisamchk_fast"></a> <a class="indexterm" name="id2700024"></a> <a class="indexterm" name="id2700037"></a> <code class="option">--fast</code>, <code class="option">-F</code> </p><p> Check only tables that haven't been closed properly. </p></li><li><p><a name="option_myisamchk_force"></a> <a class="indexterm" name="id2700070"></a> <a class="indexterm" name="id2700082"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Do a repair operation automatically if <span><strong class="command">myisamchk</strong></span> finds any errors in the table. The repair type is the same as that specified with the <code class="option">--recover</code> or <code class="option">-r</code> option. </p></li><li><p><a name="option_myisamchk_information"></a> <a class="indexterm" name="id2700130"></a> <a class="indexterm" name="id2700143"></a> <code class="option">--information</code>, <code class="option">-i</code> </p><p> Print informational statistics about the table that is checked. </p></li><li><p><a name="option_myisamchk_medium-check"></a> <a class="indexterm" name="id2700176"></a> <a class="indexterm" name="id2700189"></a> <code class="option">--medium-check</code>, <code class="option">-m</code> </p><p> Do a check that is faster than an <code class="option">--extend-check</code> operation. This finds only 99.99% of all errors, which should be good enough in most cases. </p></li><li><p><a name="option_myisamchk_read-only"></a> <a class="indexterm" name="id2700227"></a> <a class="indexterm" name="id2700240"></a> <code class="option">--read-only</code>, <code class="option">-T</code> </p><p> Don't mark the table as checked. This is useful if you use <span><strong class="command">myisamchk</strong></span> to check a table that is in use by some other application that doesn't use locking, such as <span><strong class="command">mysqld</strong></span> when run with external locking disabled. </p></li><li><p><a name="option_myisamchk_update-state"></a> <a class="indexterm" name="id2700288"></a> <a class="indexterm" name="id2700300"></a> <code class="option">--update-state</code>, <code class="option">-U</code> </p><p> Store information in the <code class="filename">.MYI</code> file to indicate when the table was checked and whether the table crashed. This should be used to get full benefit of the <code class="option">--check-only-changed</code> option, but you shouldn't use this option if the <span><strong class="command">mysqld</strong></span> server is using the table and you are running it with external locking disabled. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="myisamchk-repair-options"></a>7.4.3. <span><strong class="command">myisamchk</strong></span> Repair Options</h3></div></div></div><a class="indexterm" name="id2700361"></a><a class="indexterm" name="id2700374"></a><p> <span><strong class="command">myisamchk</strong></span> supports the following options for table repair operations: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisamchk_backup"></a> <a class="indexterm" name="id2700406"></a> <a class="indexterm" name="id2700418"></a> <code class="option">--backup</code>, <code class="option">-B</code> </p><p> Make a backup of the <code class="filename">.MYD</code> file as <code class="filename"><em class="replaceable"><code>file_name</code></em>-<em class="replaceable"><code>time</code></em>.BAK</code> </p></li><li><p><a name="option_myisamchk_character-sets-dir"></a> <a class="indexterm" name="id2700468"></a> <a class="indexterm" name="id2700481"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_myisamchk_correct-checksum"></a> <a class="indexterm" name="id2700519"></a> <a class="indexterm" name="id2700531"></a> <code class="option">--correct-checksum</code> </p><p> Correct the checksum information for the table. </p></li><li><p><a name="option_myisamchk_data-file-length"></a> <a class="indexterm" name="id2700561"></a> <a class="indexterm" name="id2700574"></a> <code class="option">--data-file-length=<em class="replaceable"><code>len</code></em>, -D <em class="replaceable"><code>len</code></em></code> </p><p> Maximum length of the data file (when re-creating data file when it is “<span class="quote">full</span>”). </p></li><li><p><a name="option_myisamchk_extended-check"></a> <a class="indexterm" name="id2700614"></a> <a class="indexterm" name="id2700626"></a> <code class="option">--extend-check</code>, <code class="option">-e</code> </p><p> Do a repair that tries to recover every possible row from the data file. Normally, this also finds a lot of garbage rows. Don't use this option unless you are desperate. </p></li><li><p> <a class="indexterm" name="id2700659"></a> <a class="indexterm" name="id2700672"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Overwrite old intermediate files (files with names like <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.TMD</code>) instead of aborting. </p></li><li><p><a name="option_myisamchk_keys-used"></a> <a class="indexterm" name="id2700714"></a> <a class="indexterm" name="id2700726"></a> <code class="option">--keys-used=<em class="replaceable"><code>val</code></em></code>, <code class="option">-k <em class="replaceable"><code>val</code></em></code> </p><p> For <span><strong class="command">myisamchk</strong></span>, the option value is a bit-value that indicates which indexes to update. Each binary bit of the option value corresponds to a table index, where the first index is bit 0. An option value of 0 disables updates to all indexes, which can be used to get faster inserts. Deactivated indexes can be reactivated by using <span><strong class="command">myisamchk -r</strong></span>. </p></li><li><p><a name="option_myisamchk_no-symlinks"></a> <a class="indexterm" name="id2700782"></a> <a class="indexterm" name="id2700794"></a> <code class="option">--no-symlinks</code>, <code class="option">-l</code> </p><p> Do not follow symbolic links. Normally <span><strong class="command">myisamchk</strong></span> repairs the table that a symlink points to. This option does not exist as of MySQL 4.0 because versions from 4.0 on do not remove symlinks during repair operations. </p></li><li><p><a name="option_myisamchk_max-record-length"></a> <a class="indexterm" name="id2700837"></a> <a class="indexterm" name="id2700849"></a> <code class="option">--max-record-length=<em class="replaceable"><code>len</code></em></code> </p><p> Skip rows larger than the given length if <span><strong class="command">myisamchk</strong></span> cannot allocate memory to hold them. </p></li><li><p><a name="option_myisamchk_parallel-recover"></a> <a class="indexterm" name="id2700888"></a> <a class="indexterm" name="id2700901"></a> <code class="option">--parallel-recover</code>, <code class="option">-p</code> </p><p> Uses the same technique as <code class="option">-r</code> and <code class="option">-n</code>, but creates all the keys in parallel, using different threads. <span class="emphasis"><em>This is beta-quality code. Use at your own risk!</em></span> </p></li><li><p><a name="optionmyisamchk_quick"></a> <a class="indexterm" name="id2700946"></a> <a class="indexterm" name="id2700959"></a> <code class="option">--quick</code>, <code class="option">-q</code> </p><p> Achieve a faster repair by not modifying the data file. You can specify this option twice to force <span><strong class="command">myisamchk</strong></span> to modify the original data file in case of duplicate keys. </p></li><li><p><a name="optionmyisamchk_recover"></a> <a class="indexterm" name="id2701000"></a> <a class="indexterm" name="id2701012"></a> <code class="option">--recover</code>, <code class="option">-r</code> </p><p> Do a repair that can fix almost any problem except unique keys that aren't unique (which is an extremely unlikely error with <code class="literal">MyISAM</code> tables). If you want to recover a table, this is the option to try first. You should try <code class="option">--safe-recover</code> only if <span><strong class="command">myisamchk</strong></span> reports that the table can't be recovered using <code class="option">--recover</code>. (In the unlikely case that <code class="option">--recover</code> fails, the data file remains intact.) </p><p> If you have lots of memory, you should increase the value of <code class="literal">sort_buffer_size</code>. </p></li><li><p><a name="option_myisamchk_safe-recover"></a> <a class="indexterm" name="id2701086"></a> <a class="indexterm" name="id2701098"></a> <code class="option">--safe-recover</code>, <code class="option">-o</code> </p><p> Do a repair using an old recovery method that reads through all rows in order and updates all index trees based on the rows found. This is an order of magnitude slower than <code class="option">--recover</code>, but can handle a couple of very unlikely cases that <code class="option">--recover</code> cannot. This recovery method also uses much less disk space than <code class="option">--recover</code>. Normally, you should repair first with <code class="option">--recover</code>, and then with <code class="option">--safe-recover</code> only if <code class="option">--recover</code> fails. </p><p> If you have lots of memory, you should increase the value of <code class="literal">key_buffer_size</code>. </p></li><li><p><a name="option_myisamchk_set-character-set"></a> <a class="indexterm" name="id2701172"></a> <a class="indexterm" name="id2701185"></a> <code class="option">--set-character-set=<em class="replaceable"><code>name</code></em></code> </p><p> Change the character set used by the table indexes. This option was replaced by <code class="option">--set-collation</code> in MySQL 5.0.3. </p></li><li><p><a name="option_myisamchk_set-collation"></a> <a class="indexterm" name="id2701222"></a> <a class="indexterm" name="id2701235"></a> <code class="option">--set-collation=<em class="replaceable"><code>name</code></em></code> </p><p> Specify the collation to use for sorting table indexes. The character set name is implied by the first part of the collation name. This option was added in MySQL 5.0.3. </p></li><li><p><a name="option_myisamchk_sort-recover"></a> <a class="indexterm" name="id2701270"></a> <a class="indexterm" name="id2701282"></a> <code class="option">--sort-recover</code>, <code class="option">-n</code> </p><p> Force <span><strong class="command">myisamchk</strong></span> to use sorting to resolve the keys even if the temporary files would be very large. </p></li><li><p><a name="option_myisamchk_tmpdir"></a> <a class="indexterm" name="id2701322"></a> <a class="indexterm" name="id2701335"></a> <code class="option">--tmpdir=<em class="replaceable"><code>path</code></em></code>, <code class="option">-t <em class="replaceable"><code>path</code></em></code> </p><p> Path of the directory to be used for storing temporary files. If this is not set, <span><strong class="command">myisamchk</strong></span> uses the value of the <code class="literal">TMPDIR</code> environment variable. <code class="literal">tmpdir</code> can be set to a list of directory paths that are used successively in round-robin fashion for creating temporary files. The separator character between directory names is the colon (“<span class="quote"><code class="literal">:</code></span>”) on Unix and the semicolon (“<span class="quote"><code class="literal">;</code></span>”) on Windows, NetWare, and OS/2. </p></li><li><p><a name="option_myisamchk_unpack"></a> <a class="indexterm" name="id2701411"></a> <a class="indexterm" name="id2701424"></a> <code class="option">--unpack</code>, <code class="option">-u</code> </p><p> Unpack a table that was packed with <span><strong class="command">myisampack</strong></span>. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="myisamchk-other-options"></a>7.4.4. Other <code class="literal">myisamchk</code> Options</h3></div></div></div><p> <span><strong class="command">myisamchk</strong></span> supports the following options for actions other than table checks and repairs: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisamchk_analyze"></a> <a class="indexterm" name="id2701490"></a> <a class="indexterm" name="id2701503"></a> <code class="option">--analyze</code>, <code class="option">-a</code> </p><p> Analyze the distribution of key values. This improves join performance by enabling the join optimizer to better choose the order in which to join the tables and which indexes it should use. To obtain information about the key distribution, use a <span><strong class="command">myisamchk --description --verbose <em class="replaceable"><code>tbl_name</code></em></strong></span> command or the <code class="literal">SHOW INDEX FROM <em class="replaceable"><code>tbl_name</code></em></code> statement. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on optimizing tables, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_myisamchk_block-search"></a> <a class="indexterm" name="id2701579"></a> <a class="indexterm" name="id2701591"></a> <code class="option">--block-search=<em class="replaceable"><code>offset</code></em></code>, <code class="option">-b <em class="replaceable"><code>offset</code></em></code> </p><p> Find the record that a block at the given offset belongs to. </p></li><li><p><a name="option_myisamchk_description"></a> <a class="indexterm" name="id2701630"></a> <a class="indexterm" name="id2701643"></a> <code class="option">--description</code>, <code class="option">-d</code> </p><p> Print some descriptive information about the table. </p></li><li><p><a name="option_myisamchk_set-auto-increment"></a> <a class="indexterm" name="id2701676"></a> <a class="indexterm" name="id2701688"></a> <code class="option">--set-auto-increment[=<em class="replaceable"><code>value</code></em>]</code>, <code class="option">-A[<em class="replaceable"><code>value</code></em>]</code> </p><p> Force <code class="literal">AUTO_INCREMENT</code> numbering for new records to start at the given value (or higher, if there are existing records with <code class="literal">AUTO_INCREMENT</code> values this large). If <em class="replaceable"><code>value</code></em> is not specified, <code class="literal">AUTO_INCREMENT</code> numbers for new records begin with the largest value currently in the table, plus one. </p></li><li><p><a name="option_myisamchk_sort-index"></a> <a class="indexterm" name="id2701755"></a> <a class="indexterm" name="id2701768"></a> <code class="option">--sort-index</code>, <code class="option">-S</code> </p><p> Sort the index tree blocks in high-low order. This optimizes seeks and makes table scans that use indexes faster. </p></li><li><p><a name="option_myisamchk_sort-records"></a> <a class="indexterm" name="id2701802"></a> <a class="indexterm" name="id2701815"></a> <code class="option">--sort-records=<em class="replaceable"><code>N</code></em></code>, <code class="option">-R <em class="replaceable"><code>N</code></em></code> </p><p> Sort records according to a particular index. This makes your data much more localized and may speed up range-based <code class="literal">SELECT</code> and <code class="literal">ORDER BY</code> operations that use this index. (The first time you use this option to sort a table, it may be very slow.) To determine a table's index numbers, use <code class="literal">SHOW INDEX</code>, which displays a table's indexes in the same order that <span><strong class="command">myisamchk</strong></span> sees them. Indexes are numbered beginning with 1. </p><p> If keys are not packed (<code class="literal">PACK_KEYS=0</code>), they have the same length, so when <span><strong class="command">myisamchk</strong></span> sorts and moves records, it just overwrites record offsets in the index. If keys are packed (<code class="literal">PACK_KEYS=1</code>), <span><strong class="command">myisamchk</strong></span> must unpack key blocks first, then re-create indexes and pack the key blocks again. (In this case, re-creating indexes is faster than updating offsets for each index.) </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="myisamchk-memory"></a>7.4.5. <span><strong class="command">myisamchk</strong></span> Memory Usage</h3></div></div></div><a class="indexterm" name="id2701925"></a><p> Memory allocation is important when you run <span><strong class="command">myisamchk</strong></span>. <span><strong class="command">myisamchk</strong></span> uses no more memory than its memory-related variables are set to. If you are going to use <span><strong class="command">myisamchk</strong></span> on very large tables, you should first decide how much memory you want it to use. The default is to use only about 3MB to perform repairs. By using larger values, you can get <span><strong class="command">myisamchk</strong></span> to operate faster. For example, if you have more than 32MB RAM, you could use options such as these (in addition to any other options you might specify): </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk --sort_buffer_size=16M --key_buffer_size=16M \</code></strong> <strong class="userinput"><code>--read_buffer_size=1M --write_buffer_size=1M ...</code></strong> </pre><p> Using <code class="option">--sort_buffer_size=16M</code> should probably be enough for most cases. </p><p> Be aware that <span><strong class="command">myisamchk</strong></span> uses temporary files in <code class="literal">TMPDIR</code>. If <code class="literal">TMPDIR</code> points to a memory filesystem, you may easily get out of memory errors. If this happens, run <span><strong class="command">myisamchk</strong></span> with the <code class="option">--tmpdir=<em class="replaceable"><code>path</code></em></code> option to specify some directory located on a filesystem that has more space. </p><p> When repairing, <span><strong class="command">myisamchk</strong></span> also needs a lot of disk space: </p><div class="itemizedlist"><ul type="disc"><li><p> Double the size of the data file (the original file and a copy). This space is not needed if you do a repair with <code class="option">--quick</code>; in this case, only the index file is re-created. This space is needed on the same filesystem as the original data file! (The copy is created in the same directory as the original.) </p></li><li><p> Space for the new index file that replaces the old one. The old index file is truncated at the start of the repair operation, so you usually ignore this space. This space is needed on the same filesystem as the original index file! </p></li><li><p> When using <code class="option">--recover</code> or <code class="option">--sort-recover</code> (but not when using <code class="option">--safe-recover</code>), you need space for a sort buffer. The following formula yields the amount of space required: </p><pre class="programlisting">(<em class="replaceable"><code>largest_key</code></em> + <em class="replaceable"><code>row_pointer_length</code></em>) × <em class="replaceable"><code>number_of_rows</code></em> × 2 </pre><p> You can check the length of the keys and the <code class="literal">row_pointer_length</code> with <span><strong class="command">myisamchk -dv <em class="replaceable"><code>tbl_name</code></em></strong></span>. This space is allocated in the temporary directory (specified by <code class="literal">TMPDIR</code> or <code class="option">--tmpdir=<em class="replaceable"><code>path</code></em></code>). </p></li></ul></div><p> If you have a problem with disk space during repair, you can try <code class="option">--safe-recover</code> instead of <code class="option">--recover</code>. </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="myisamlog"></a>7.5. <span><strong class="command">myisamlog</strong></span> — Display MyISAM Log File Contents</h2></div></div></div><p> <span><strong class="command">myisamlog</strong></span> processes the contents of a <code class="literal">MyISAM</code> log file. </p><p> Invoke <span><strong class="command">myisamlog</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamlog [<em class="replaceable"><code>options</code></em>] [<em class="replaceable"><code>log_file</code></em> [<em class="replaceable"><code>tbl_name</code></em>] ...]</code></strong> shell> <strong class="userinput"><code>isamlog [<em class="replaceable"><code>options</code></em>] [<em class="replaceable"><code>log_file</code></em> [<em class="replaceable"><code>tbl_name</code></em>] ...]</code></strong> </pre><p> The default operation is update (<code class="option">-u</code>). If a recovery is done (<code class="option">-r</code>), all writes and possibly updates and deletes are done and errors are only counted. The default log file name is <code class="filename">myisam.log</code> for <span><strong class="command">myisamlog</strong></span> and <code class="filename">isam.log</code> for <span><strong class="command">isamlog</strong></span> if no <em class="replaceable"><code>log_file</code></em> argument is given, If tables are named on the command line, only those tables are updated. </p><p> <span><strong class="command">myisamlog</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisamlog_help"></a> <code class="option">-?</code>, <code class="option">-I</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_myisamlog_commands"></a> <code class="option">-c <em class="replaceable"><code>N</code></em></code> </p><p> Execute only <em class="replaceable"><code>N</code></em> commands. </p></li><li><p><a name="option_myisamlog_files"></a> <code class="option">-f <em class="replaceable"><code>N</code></em></code> </p><p> Specify the maximum number of open files. </p></li><li><p><a name="option_myisamlog_information"></a> <code class="option">-i</code> </p><p> Display extra information before exiting. </p></li><li><p><a name="option_myisamlog_offset"></a> <code class="option">-o <em class="replaceable"><code>offset</code></em></code> </p><p> Specify the starting offset. </p></li><li><p><a name="option_myisamlog_path"></a> <code class="option">-p <em class="replaceable"><code>N</code></em></code> </p><p> Remove <em class="replaceable"><code>N</code></em> components from path. </p></li><li><p><a name="option_myisamlog_recovery"></a> <code class="option">-r</code> </p><p> Perform a recovery operation. </p></li><li><p><a name="option_myisamlog_record-position"></a> <code class="option">-R <em class="replaceable"><code>record_pos_file record_pos</code></em></code> </p><p> Specify record position file and record position. </p></li><li><p><a name="option_myisamlog_update"></a> <code class="option">-u</code> </p><p> Perform an update operation. </p></li><li><p><a name="option_myisamlog_verbose"></a> <code class="option">-v</code> </p><p> Verbose mode. Print more output about what the program does. This option can be given multiple times to produce more and more output. </p></li><li><p><a name="option_myisamlog_write"></a> <code class="option">-w <em class="replaceable"><code>write_file</code></em></code> </p><p> Specify the write file. </p></li><li><p><a name="option_myisamlog_version"></a> <code class="option">-V</code> </p><p> Display version information. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="myisampack"></a>7.6. <span><strong class="command">myisampack</strong></span> — Generate Compressed, Read-Only MyISAM Tables</h2></div></div></div><p> The <span><strong class="command">myisampack</strong></span> utility compresses <code class="literal">MyISAM</code> tables. <span><strong class="command">myisampack</strong></span> works by compressing each column in the table separately. Usually, <span><strong class="command">myisampack</strong></span> packs the data file 40%-70%. </p><p> When the table is used later, the server reads into memory the information needed to decompress columns. This results in much better performance when accessing individual rows, because you only have to uncompress exactly one row. </p><p> MySQL uses <code class="literal">mmap()</code> when possible to perform memory mapping on compressed tables. If <code class="literal">mmap()</code> does not work, MySQL falls back to normal read/write file operations. </p><p> Please note the following: </p><div class="itemizedlist"><ul type="disc"><li><p> If the <span><strong class="command">mysqld</strong></span> server was invoked with external locking disabled, it is not a good idea to invoke <span><strong class="command">myisampack</strong></span> if the table might be updated by the server during the packing process. It is safest to compress tables with the server stopped. </p></li><li><p> After packing a table, it becomes read only. This is generally intended (such as when accessing packed tables on a CD). Allowing writes to a packed table is on our TODO list, but with low priority. </p></li></ul></div><p> Invoke <span><strong class="command">myisampack</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisampack [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>file_name</code></em> ...</code></strong> </pre><p> Each filename argument should be the name of an index (<code class="filename">.MYI</code>) file. If you are not in the database directory, you should specify the pathname to the file. It is permissible to omit the <code class="filename">.MYI</code> extension. </p><p> After you compress a table with <span><strong class="command">myisampack</strong></span>, you should use <span><strong class="command">myisamchk -rq</strong></span> to rebuild its indexes. <a href="client-utility-programs.html#myisamchk" title="7.4. myisamchk — MyISAM Table-Maintenance Utility">Section 7.4, “<span><strong class="command">myisamchk</strong></span> — MyISAM Table-Maintenance Utility”</a>. </p><p> <span><strong class="command">myisampack</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_myisampack_help"></a> <a class="indexterm" name="id2702726"></a> <a class="indexterm" name="id2702738"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_myisampack_backup"></a> <a class="indexterm" name="id2702771"></a> <a class="indexterm" name="id2702783"></a> <code class="option">--backup</code>, <code class="option">-b</code> </p><p> Make a backup of each table's data file using the name <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.OLD</code>. </p></li><li><p><a name="option_myisampack_character-sets-dir"></a> <a class="indexterm" name="id2702825"></a> <a class="indexterm" name="id2702838"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_myisampack_debug"></a> <a class="indexterm" name="id2702875"></a> <a class="indexterm" name="id2702888"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_myisampack_force"></a> <a class="indexterm" name="id2702942"></a> <a class="indexterm" name="id2702954"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Produce a packed table even if it becomes larger than the original or if the intermediate file from an earlier invocation of <span><strong class="command">myisampack</strong></span> exists. (<span><strong class="command">myisampack</strong></span> creates an intermediate file named <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.TMD</code> in the database directory while it compresses the table. If you kill <span><strong class="command">myisampack</strong></span>, the <code class="filename">.TMD</code> file might not be deleted.) Normally, <span><strong class="command">myisampack</strong></span> exits with an error if it finds that <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.TMD</code> exists. With <code class="option">--force</code>, <span><strong class="command">myisampack</strong></span> packs the table anyway. </p></li><li><p><a name="option_myisampack_join"></a> <a class="indexterm" name="id2703051"></a> <a class="indexterm" name="id2703063"></a> <code class="option">--join=<em class="replaceable"><code>big_tbl_name</code></em></code>, <code class="option">-j <em class="replaceable"><code>big_tbl_name</code></em></code> </p><p> Join all tables named on the command line into a single table <em class="replaceable"><code>big_tbl_name</code></em>. All tables that are to be combined <span class="emphasis"><em>must</em></span> have identical structure (same column names and types, same indexes, and so forth). </p></li><li><p><a name="option_myisampack_silent"></a> <a class="indexterm" name="id2703112"></a> <a class="indexterm" name="id2703125"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Write output only when errors occur. </p></li><li><p><a name="option_myisampack_test"></a> <a class="indexterm" name="id2703158"></a> <a class="indexterm" name="id2703170"></a> <code class="option">--test</code>, <code class="option">-t</code> </p><p> Do not actually pack the table, just test packing it. </p></li><li><p><a name="option_myisampack_tmpdir"></a> <a class="indexterm" name="id2703203"></a> <a class="indexterm" name="id2703215"></a> <code class="option">--tmpdir=<em class="replaceable"><code>path</code></em></code>, <code class="option">-T <em class="replaceable"><code>path</code></em></code> </p><p> Use the named directory as the location where <span><strong class="command">myisampack</strong></span> creates temporary files. </p></li><li><p><a name="option_myisampack_verbose"></a> <a class="indexterm" name="id2703260"></a> <a class="indexterm" name="id2703272"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Write information about the progress of the packing operation and its result. </p></li><li><p><a name="option_myisampack_version"></a> <a class="indexterm" name="id2703306"></a> <a class="indexterm" name="id2703319"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li><li><p><a name="option_myisampack_wait"></a> <a class="indexterm" name="id2703351"></a> <a class="indexterm" name="id2703364"></a> <code class="option">--wait</code>, <code class="option">-w</code> </p><p> Wait and retry if the table is in use. If the <span><strong class="command">mysqld</strong></span> server was invoked with external locking disabled, it is not a good idea to invoke <span><strong class="command">myisampack</strong></span> if the table might be updated by the server during the packing process. </p></li></ul></div><a class="indexterm" name="id2703406"></a><p> The following sequence of commands illustrates a typical table compression session: </p><pre class="programlisting">shell> <strong class="userinput"><code>ls -l station.*</code></strong> -rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.MYD -rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.MYI -rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm shell> <strong class="userinput"><code>myisamchk -dvv station</code></strong> MyISAM file: station Isam-version: 2 Creation time: 1996-03-13 10:08:58 Recover time: 1997-02-02 3:06:43 Data records: 1192 Deleted blocks: 0 Datafile parts: 1192 Deleted data: 0 Datafile pointer (bytes): 2 Keyfile pointer (bytes): 2 Max datafile length: 54657023 Max keyfile length: 33554431 Recordlength: 834 Record format: Fixed length table description: Key Start Len Index Type Root Blocksize Rec/key 1 2 4 unique unsigned long 1024 1024 1 2 32 30 multip. text 10240 1024 1 Field Start Length Type 1 1 1 2 2 4 3 6 4 4 10 1 5 11 20 6 31 1 7 32 30 8 62 35 9 97 35 10 132 35 11 167 4 12 171 16 13 187 35 14 222 4 15 226 16 16 242 20 17 262 20 18 282 20 19 302 30 20 332 4 21 336 4 22 340 1 23 341 8 24 349 8 25 357 8 26 365 2 27 367 2 28 369 4 29 373 4 30 377 1 31 378 2 32 380 8 33 388 4 34 392 4 35 396 4 36 400 4 37 404 1 38 405 4 39 409 4 40 413 4 41 417 4 42 421 4 43 425 4 44 429 20 45 449 30 46 479 1 47 480 1 48 481 79 49 560 79 50 639 79 51 718 79 52 797 8 53 805 1 54 806 1 55 807 20 56 827 4 57 831 4 shell> <strong class="userinput"><code>myisampack station.MYI</code></strong> Compressing station.MYI: (1192 records) - Calculating statistics normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11 pre-space: 0 end-space: 12 table-lookups: 5 zero: 7 Original trees: 57 After join: 17 - Compressing file 87.14% Remember to run myisamchk -rq on compressed tables shell> <strong class="userinput"><code>ls -l station.*</code></strong> -rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.MYD -rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.MYI -rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm shell> <strong class="userinput"><code>myisamchk -dvv station</code></strong> MyISAM file: station Isam-version: 2 Creation time: 1996-03-13 10:08:58 Recover time: 1997-04-17 19:04:26 Data records: 1192 Deleted blocks: 0 Datafile parts: 1192 Deleted data: 0 Datafile pointer (bytes): 3 Keyfile pointer (bytes): 1 Max datafile length: 16777215 Max keyfile length: 131071 Recordlength: 834 Record format: Compressed table description: Key Start Len Index Type Root Blocksize Rec/key 1 2 4 unique unsigned long 10240 1024 1 2 32 30 multip. text 54272 1024 1 Field Start Length Type Huff tree Bits 1 1 1 constant 1 0 2 2 4 zerofill(1) 2 9 3 6 4 no zeros, zerofill(1) 2 9 4 10 1 3 9 5 11 20 table-lookup 4 0 6 31 1 3 9 7 32 30 no endspace, not_always 5 9 8 62 35 no endspace, not_always, no empty 6 9 9 97 35 no empty 7 9 10 132 35 no endspace, not_always, no empty 6 9 11 167 4 zerofill(1) 2 9 12 171 16 no endspace, not_always, no empty 5 9 13 187 35 no endspace, not_always, no empty 6 9 14 222 4 zerofill(1) 2 9 15 226 16 no endspace, not_always, no empty 5 9 16 242 20 no endspace, not_always 8 9 17 262 20 no endspace, no empty 8 9 18 282 20 no endspace, no empty 5 9 19 302 30 no endspace, no empty 6 9 20 332 4 always zero 2 9 21 336 4 always zero 2 9 22 340 1 3 9 23 341 8 table-lookup 9 0 24 349 8 table-lookup 10 0 25 357 8 always zero 2 9 26 365 2 2 9 27 367 2 no zeros, zerofill(1) 2 9 28 369 4 no zeros, zerofill(1) 2 9 29 373 4 table-lookup 11 0 30 377 1 3 9 31 378 2 no zeros, zerofill(1) 2 9 32 380 8 no zeros 2 9 33 388 4 always zero 2 9 34 392 4 table-lookup 12 0 35 396 4 no zeros, zerofill(1) 13 9 36 400 4 no zeros, zerofill(1) 2 9 37 404 1 2 9 38 405 4 no zeros 2 9 39 409 4 always zero 2 9 40 413 4 no zeros 2 9 41 417 4 always zero 2 9 42 421 4 no zeros 2 9 43 425 4 always zero 2 9 44 429 20 no empty 3 9 45 449 30 no empty 3 9 46 479 1 14 4 47 480 1 14 4 48 481 79 no endspace, no empty 15 9 49 560 79 no empty 2 9 50 639 79 no empty 2 9 51 718 79 no endspace 16 9 52 797 8 no empty 2 9 53 805 1 17 1 54 806 1 3 9 55 807 20 no empty 3 9 56 827 4 no zeros, zerofill(2) 2 9 57 831 4 no zeros, zerofill(1) 2 9 </pre><p> <span><strong class="command">myisampack</strong></span> displays the following kinds of information: </p><div class="itemizedlist"><ul type="disc"><li><p> <code class="literal">normal</code> </p><p> The number of columns for which no extra packing is used. </p></li><li><p> <code class="literal">empty-space</code> </p><p> The number of columns containing values that are only spaces. These occupy one bit. </p></li><li><p> <code class="literal">empty-zero</code> </p><p> The number of columns containing values that are only binary zeros. These occupy one bit. </p></li><li><p> <code class="literal">empty-fill</code> </p><p> The number of integer columns that do not occupy the full byte range of their type. These are changed to a smaller type. For example, a <code class="literal">BIGINT</code> column (eight bytes) can be stored as a <code class="literal">TINYINT</code> column (one byte) if all its values are in the range from <code class="literal">-128</code> to <code class="literal">127</code>. </p></li><li><p> <code class="literal">pre-space</code> </p><p> The number of decimal columns that are stored with leading spaces. In this case, each value contains a count for the number of leading spaces. </p></li><li><p> <code class="literal">end-space</code> </p><p> The number of columns that have a lot of trailing spaces. In this case, each value contains a count for the number of trailing spaces. </p></li><li><p> <code class="literal">table-lookup</code> </p><p> The column had only a small number of different values, which were converted to an <code class="literal">ENUM</code> before Huffman compression. </p></li><li><p> <code class="literal">zero</code> </p><p> The number of columns for which all values are zero. </p></li><li><p> <code class="literal">Original trees</code> </p><p> The initial number of Huffman trees. </p></li><li><p> <code class="literal">After join</code> </p><p> The number of distinct Huffman trees left after joining trees to save some header space. </p></li></ul></div><p> After a table has been compressed, <span><strong class="command">myisamchk -dvv</strong></span> prints additional information about each column: </p><div class="itemizedlist"><ul type="disc"><li><p> <code class="literal">Type</code> </p><p> The data type. The value may contain any of the following descriptors: </p><div class="itemizedlist"><ul type="circle"><li><p> <code class="literal">constant</code> </p><p> All rows have the same value. </p></li><li><p> <code class="literal">no endspace</code> </p><p> Do not store endspace. </p></li><li><p> <code class="literal">no endspace, not_always</code> </p><p> Do not store endspace and do not do endspace compression for all values. </p></li><li><p> <code class="literal">no endspace, no empty</code> </p><p> Do not store endspace. Do not store empty values. </p></li><li><p> <code class="literal">table-lookup</code> </p><p> The column was converted to an <code class="literal">ENUM</code>. </p></li><li><p> <code class="literal">zerofill(<em class="replaceable"><code>N</code></em>)</code> </p><p> The most significant <em class="replaceable"><code>N</code></em> bytes in the value are always 0 and are not stored. </p></li><li><p> <code class="literal">no zeros</code> </p><p> Do not store zeros. </p></li><li><p> <code class="literal">always zero</code> </p><p> Zero values are stored using one bit. </p></li></ul></div></li><li><p> <code class="literal">Huff tree</code> </p><p> The number of the Huffman tree associated with the column. </p></li><li><p> <code class="literal">Bits</code> </p><p> The number of bits used in the Huffman tree. </p></li></ul></div><p> After you run <span><strong class="command">myisampack</strong></span>, you must run <span><strong class="command">myisamchk</strong></span> to re-create any indexes. At this time, you can also sort the index blocks and create statistics needed for the MySQL optimizer to work more efficiently: </p><pre class="programlisting">shell> <strong class="userinput"><code>myisamchk -rq --sort-index --analyze <em class="replaceable"><code>tbl_name</code></em>.MYI</code></strong> </pre><p> After you have installed the packed table into the MySQL database directory, you should execute <span><strong class="command">mysqladmin flush-tables</strong></span> to force <span><strong class="command">mysqld</strong></span> to start using the new table. </p><p> To unpack a packed table, use the <code class="option">--unpack</code> option to <span><strong class="command">myisamchk</strong></span>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql"></a>7.7. <span><strong class="command">mysql</strong></span> — The MySQL Command-Line Tool</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="client-utility-programs.html#mysql-command-options">7.7.1. <span><strong class="command">mysql</strong></span> Options</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-commands">7.7.2. <span><strong class="command">mysql</strong></span> Commands</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-server-side-help">7.7.3. <span><strong class="command">mysql</strong></span> Server-Side Help</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#batch-commands">7.7.4. Executing SQL Statements from a Text File</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-tips">7.7.5. <span><strong class="command">mysql</strong></span> Tips</a></span></dt></dl></div><p> <span><strong class="command">mysql</strong></span> is a simple SQL shell (with GNU <code class="literal">readline</code> capabilities). It supports interactive and non-interactive use. When used interactively, query results are presented in an ASCII-table format. When used non-interactively (for example, as a filter), the result is presented in tab-separated format. The output format can be changed using command options. </p><p> If you have problems due to insufficient memory for large result sets, use the <code class="option">--quick</code> option. This forces <span><strong class="command">mysql</strong></span> to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the <a href="apis.html#mysql-use-result" title="23.2.3.71. mysql_use_result()"><code class="literal">mysql_use_result()</code></a> C API function in the client/server library rather than <a href="apis.html#mysql-store-result" title="23.2.3.69. mysql_store_result()"><code class="literal">mysql_store_result()</code></a>. </p><p> Using <span><strong class="command">mysql</strong></span> is very easy. Invoke it from the prompt of your command interpreter as follows: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> Or: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql --user=<em class="replaceable"><code>user_name</code></em> --password=<em class="replaceable"><code>your_password</code></em> <em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> Then type an SQL statement, end it with “<span class="quote"><code class="literal">;</code></span>”, <code class="literal">\g</code>, or <code class="literal">\G</code> and press Enter. </p><p> As of MySQL 5.0.25, typing Control-C causes <span><strong class="command">mysql</strong></span> to attempt to kill the current statement. If this cannot be done, or Control-C is typed again before the statement is killed, <span><strong class="command">mysql</strong></span> exits. Previously, Control-C caused <span><strong class="command">mysql</strong></span> to exit in all cases. </p><p> You can execute SQL statements in a script file (batch file) like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em> < <em class="replaceable"><code>script.sql</code></em> > <em class="replaceable"><code>output.tab</code></em></code></strong> </pre><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-command-options"></a>7.7.1. <span><strong class="command">mysql</strong></span> Options</h3></div></div></div><a class="indexterm" name="id2704397"></a><a class="indexterm" name="id2704406"></a><a class="indexterm" name="id2704419"></a><a class="indexterm" name="id2704435"></a><p> <span><strong class="command">mysql</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_help"></a> <a class="indexterm" name="id2704466"></a> <a class="indexterm" name="id2704478"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_auto-rehash"></a> <a class="indexterm" name="id2704510"></a> <a class="indexterm" name="id2704523"></a> <code class="option">--auto-rehash</code> </p><p> Enable automatic rehashing. This option is on by default, which enables table and column name completion. Use <code class="option">--skip-auto-rehash</code> to disable rehashing. That causes <span><strong class="command">mysql</strong></span> to start faster, but you must issue the <code class="literal">rehash</code> command if you want to use table and column name completion. </p></li><li><p><a name="option_mysql_batch"></a> <a class="indexterm" name="id2704572"></a> <a class="indexterm" name="id2704585"></a> <code class="option">--batch</code>, <code class="option">-B</code> </p><p> Print results using tab as the column separator, with each row on a new line. With this option, <span><strong class="command">mysql</strong></span> does not use the history file. </p></li><li><p><a name="option_mysql_character-sets-dir"></a> <a class="indexterm" name="id2704626"></a> <a class="indexterm" name="id2704638"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysql_column-names"></a> <a class="indexterm" name="id2704676"></a> <a class="indexterm" name="id2704688"></a> <code class="option">--column-names</code> </p><p> Write column names in results. </p></li><li><p><a name="option_mysql_comments"></a> <a class="indexterm" name="id2704718"></a> <a class="indexterm" name="id2704730"></a> <code class="option">--comments</code>, <code class="option">-c</code> </p><p> Whether to preserve comments in statements sent to the server. The default is --skip-comments (discard comments), enable with --comments (preserve comments). This option was added in MySQL 5.0.52. </p></li><li><p><a name="option_mysql_compress"></a> <a class="indexterm" name="id2704766"></a> <a class="indexterm" name="id2704778"></a> <code class="option">--compress</code>, <code class="option">-C</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysql_database"></a> <a class="indexterm" name="id2704812"></a> <a class="indexterm" name="id2704825"></a> <code class="option">--database=<em class="replaceable"><code>db_name</code></em></code>, <code class="option">-D <em class="replaceable"><code>db_name</code></em></code> </p><p> The database to use. This is useful primarily in an option file. </p></li><li><p><a name="option_mysql_debug"></a> <a class="indexterm" name="id2704863"></a> <a class="indexterm" name="id2704876"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. The default is <code class="literal">'d:t:o,/tmp/mysql.trace'</code>. </p></li><li><p><a name="option_mysql_debug-info"></a> <a class="indexterm" name="id2704937"></a> <a class="indexterm" name="id2704950"></a> <code class="option">--debug-info</code>, <code class="option">-T</code> </p><p> Print some debugging information when the program exits. </p></li><li><p><a name="option_mysql_default-character-set"></a> <a class="indexterm" name="id2704983"></a> <a class="indexterm" name="id2704996"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysql_delimiter"></a> <a class="indexterm" name="id2705037"></a> <a class="indexterm" name="id2705050"></a> <code class="option">--delimiter=<em class="replaceable"><code>str</code></em></code> </p><p> Set the statement delimiter. The default is the semicolon character (“<span class="quote"><code class="literal">;</code></span>”). </p></li><li><p><a name="option_mysql_execute"></a> <a class="indexterm" name="id2705089"></a> <a class="indexterm" name="id2705101"></a> <code class="option">--execute=<em class="replaceable"><code>statement</code></em></code>, <code class="option">-e <em class="replaceable"><code>statement</code></em></code> </p><p> Execute the statement and quit. The default output format is like that produced with <code class="option">--batch</code>. See <a href="using-mysql-programs.html#command-line-options" title="4.3.1. Using Options on the Command Line">Section 4.3.1, “Using Options on the Command Line”</a>, for some examples. </p></li><li><p><a name="option_mysql_force"></a> <a class="indexterm" name="id2705149"></a> <a class="indexterm" name="id2705162"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Continue even if an SQL error occurs. </p></li><li><p><a name="option_mysql_host"></a> <a class="indexterm" name="id2705194"></a> <a class="indexterm" name="id2705206"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysql_html"></a> <a class="indexterm" name="id2705244"></a> <a class="indexterm" name="id2705256"></a> <code class="option">--html</code>, <code class="option">-H</code> </p><p> Produce HTML output. </p></li><li><p><a name="option_mysql_ignore-spaces"></a> <a class="indexterm" name="id2705288"></a> <a class="indexterm" name="id2705301"></a> <code class="option">--ignore-spaces</code>, <code class="option">-i</code> </p><p> Ignore spaces after function names. The effect of this is described in the discussion for the <code class="literal">IGNORE_SPACE</code> SQL mode (see <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>). </p></li><li><p><a name="option_mysql_line-numbers"></a> <a class="indexterm" name="id2705347"></a> <a class="indexterm" name="id2705359"></a> <code class="option">--line-numbers</code> </p><p> Write line numbers for errors. Disable this with <code class="option">--skip-line-numbers</code>. </p></li><li><p><a name="option_mysql_local-infile"></a> <a class="indexterm" name="id2705393"></a> <a class="indexterm" name="id2705405"></a> <code class="option">--local-infile[={0|1}]</code> </p><p> Enable or disable <code class="literal">LOCAL</code> capability for <code class="literal">LOAD DATA INFILE</code>. With no value, the option enables <code class="literal">LOCAL</code>. The option may be given as <code class="option">--local-infile=0</code> or <code class="option">--local-infile=1</code> to explicitly disable or enable <code class="literal">LOCAL</code>. Enabling <code class="literal">LOCAL</code> has no effect if the server does not also support it. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on the security implications of enabling <code class="literal">LOCAL</code>, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_mysql_named-commands"></a> <a class="indexterm" name="id2705503"></a> <a class="indexterm" name="id2705516"></a> <code class="option">--named-commands</code>, <code class="option">-G</code> </p><p> Enable named <span><strong class="command">mysql</strong></span> commands. Long-format commands are allowed, not just short-format commands. For example, <code class="literal">quit</code> and <code class="literal">\q</code> both are recognized. Use <code class="option">--skip-named-commands</code> to disable named commands. See <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>. </p></li><li><p><a name="option_mysql_no-auto-rehash"></a> <a class="indexterm" name="id2705578"></a> <a class="indexterm" name="id2705591"></a> <code class="option">--no-auto-rehash</code>, <code class="option">-A</code> </p><p> Deprecated form of <code class="option">-skip-auto-rehash</code>. See the description for <code class="option">--auto-rehash</code>. </p></li><li><p><a name="option_mysql_no-beep"></a> <a class="indexterm" name="id2705632"></a> <a class="indexterm" name="id2705644"></a> <code class="option">--no-beep</code>, <code class="option">-b</code> </p><p> Do not beep when errors occur. </p></li><li><p><a name="option_mysql_no-named-commands"></a> <a class="indexterm" name="id2705677"></a> <a class="indexterm" name="id2705689"></a> <code class="option">--no-named-commands</code>, <code class="option">-g</code> </p><p> Disable named commands. Use the <code class="literal">\*</code> form only, or use named commands only at the beginning of a line ending with a semicolon (“<span class="quote"><code class="literal">;</code></span>”). <span><strong class="command">mysql</strong></span> starts with this option <span class="emphasis"><em>enabled</em></span> by default. However, even with this option, long-format commands still work from the first line. See <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>. </p></li><li><p><a name="option_mysql_no-pager"></a> <a class="indexterm" name="id2705754"></a> <a class="indexterm" name="id2705767"></a> <code class="option">--no-pager</code> </p><p> Deprecated form of <code class="option">--skip-pager</code>. See the <code class="option">--pager</code> option. </p></li><li><p><a name="option_mysql_no-tee"></a> <a class="indexterm" name="id2705804"></a> <a class="indexterm" name="id2705816"></a> <code class="option">--no-tee</code> </p><p> Do not copy output to a file. <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>, discusses tee files further. </p></li><li><p><a name="option_mysql_one-database"></a> <a class="indexterm" name="id2705851"></a> <a class="indexterm" name="id2705863"></a> <code class="option">--one-database</code>, <code class="option">-o</code> </p><p> Ignore statements except those for the default database named on the command line. This is useful for skipping updates to other databases in the binary log. </p></li><li><p><a name="option_mysql_pager"></a> <a class="indexterm" name="id2705898"></a> <a class="indexterm" name="id2705911"></a> <code class="option">--pager[=<em class="replaceable"><code>command</code></em>]</code> </p><p> Use the given command for paging query output. If the command is omitted, the default pager is the value of your <code class="literal">PAGER</code> environment variable. Valid pagers are <span><strong class="command">less</strong></span>, <span><strong class="command">more</strong></span>, <span><strong class="command">cat [> filename]</strong></span>, and so forth. This option works only on Unix. It does not work in batch mode. To disable paging, use <code class="option">--skip-pager</code>. <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>, discusses output paging further. </p></li><li><p><a name="option_mysql_password"></a> <a class="indexterm" name="id2705983"></a> <a class="indexterm" name="id2705995"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysql_port"></a> <a class="indexterm" name="id2706068"></a> <a class="indexterm" name="id2706080"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysql_prompt"></a> <a class="indexterm" name="id2706118"></a> <a class="indexterm" name="id2706130"></a> <code class="option">--prompt=<em class="replaceable"><code>format_str</code></em></code> </p><p> Set the prompt to the specified format. The default is <code class="literal">mysql></code>. The special sequences that the prompt can contain are described in <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>. </p></li><li><p><a name="option_mysql_protocol"></a> <a class="indexterm" name="id2706175"></a> <a class="indexterm" name="id2706188"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysql_quick"></a> <a class="indexterm" name="id2706217"></a> <a class="indexterm" name="id2706230"></a> <code class="option">--quick</code>, <code class="option">-q</code> </p><p> Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option, <span><strong class="command">mysql</strong></span> does not use the history file. </p></li><li><p><a name="option_mysql_raw"></a> <a class="indexterm" name="id2706271"></a> <a class="indexterm" name="id2706283"></a> <code class="option">--raw</code>, <code class="option">-r</code> </p><p> Write column values without escape conversion. Often used with the <code class="option">--batch</code> option. </p></li><li><p><a name="option_mysql_reconnect"></a> <a class="indexterm" name="id2706320"></a> <a class="indexterm" name="id2706333"></a> <code class="option">--reconnect</code> </p><p> If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. To suppress reconnection behavior, use <code class="option">--skip-reconnect</code>. </p></li><li><p><a name="option_mysql_safe-updates"></a> <a class="indexterm" name="id2706369"></a> <a class="indexterm" name="id2706382"></a> <a class="indexterm" name="id2706394"></a> <a class="indexterm" name="id2706407"></a> <code class="option">--safe-updates</code>, <code class="option">--i-am-a-dummy</code>, <code class="option">-U</code> </p><p> Allow only those <code class="literal">UPDATE</code> and <code class="literal">DELETE</code> statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using <code class="option">--safe-updates</code> on the command line. See <a href="client-utility-programs.html#mysql-tips" title="7.7.5. mysql Tips">Section 7.7.5, “<span><strong class="command">mysql</strong></span> Tips”</a>, for more information about this option. </p></li><li><p><a name="option_mysql_secure_auth"></a> <a class="indexterm" name="id2706468"></a> <a class="indexterm" name="id2706480"></a> <code class="option">--secure-auth</code> </p><p> Do not send passwords to the server in old (pre-4.1.1) format. This prevents connections except for servers that use the newer password format. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on database security, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_mysql_show-warnings"></a> <a class="indexterm" name="id2706533"></a> <a class="indexterm" name="id2706546"></a> <code class="option">--show-warnings</code> </p><p> Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode. This option was added in MySQL 5.0.6. </p></li><li><p><a name="option_mysql_sigint-ignore"></a> <a class="indexterm" name="id2706578"></a> <a class="indexterm" name="id2706590"></a> <code class="option">--sigint-ignore</code> </p><p> Ignore <code class="literal">SIGINT</code> signals (typically the result of typing Control-C). </p></li><li><p><a name="option_mysql_silent"></a> <a class="indexterm" name="id2706626"></a> <a class="indexterm" name="id2706639"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Produce less output. This option can be given multiple times to produce less and less output. </p></li><li><p><a name="option_mysql_skip-column-names"></a> <a class="indexterm" name="id2706673"></a> <a class="indexterm" name="id2706686"></a> <code class="option">--skip-column-names</code>, <code class="option">-N</code> </p><p> Do not write column names in results. </p></li><li><p><a name="option_mysql_skip-line-numbers"></a> <a class="indexterm" name="id2706718"></a> <a class="indexterm" name="id2706731"></a> <code class="option">--skip-line-numbers</code>, <code class="option">-L</code> </p><p> Do not write line numbers for errors. Useful when you want to compare result files that include error messages. </p></li><li><p><a name="option_mysql_socket"></a> <a class="indexterm" name="id2706765"></a> <a class="indexterm" name="id2706778"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysql_ssl"></a> <a class="indexterm" name="id2706823"></a> <a class="indexterm" name="id2706836"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysql_table"></a> <a class="indexterm" name="id2706875"></a> <a class="indexterm" name="id2706888"></a> <code class="option">--table</code>, <code class="option">-t</code> </p><p> Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode. </p></li><li><p><a name="option_mysql_tee"></a> <a class="indexterm" name="id2706922"></a> <a class="indexterm" name="id2706934"></a> <code class="option">--tee=<em class="replaceable"><code>file_name</code></em></code> </p><p> Append a copy of output to the given file. This option does not work in batch mode. in <a href="client-utility-programs.html#mysql-commands" title="7.7.2. mysql Commands">Section 7.7.2, “<span><strong class="command">mysql</strong></span> Commands”</a>, discusses tee files further. </p></li><li><p><a name="option_mysql_unbuffered"></a> <a class="indexterm" name="id2706973"></a> <a class="indexterm" name="id2706985"></a> <code class="option">--unbuffered</code>, <code class="option">-n</code> </p><p> Flush the buffer after each query. </p></li><li><p><a name="option_mysql_user"></a> <a class="indexterm" name="id2707018"></a> <a class="indexterm" name="id2707030"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysql_verbose"></a> <a class="indexterm" name="id2707068"></a> <a class="indexterm" name="id2707081"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example, <code class="option">-v -v -v</code> produces table output format even in batch mode.) </p></li><li><p><a name="option_mysql_version"></a> <a class="indexterm" name="id2707121"></a> <a class="indexterm" name="id2707133"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li><li><p><a name="option_mysql_vertical"></a> <a class="indexterm" name="id2707166"></a> <a class="indexterm" name="id2707178"></a> <code class="option">--vertical</code>, <code class="option">-E</code> </p><p> Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with <code class="literal">\G</code>. </p></li><li><p><a name="option_mysql_wait"></a> <a class="indexterm" name="id2707219"></a> <a class="indexterm" name="id2707232"></a> <code class="option">--wait</code>, <code class="option">-w</code> </p><p> If the connection cannot be established, wait and retry instead of aborting. </p></li><li><p><a name="option_mysql_xml"></a> <a class="indexterm" name="id2707265"></a> <a class="indexterm" name="id2707277"></a> <code class="option">--xml</code>, <code class="option">-X</code> </p><p> Produce XML output. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> Prior to MySQL 5.0.26, there was no differentiation in the output when using this option between columns containing the <code class="literal">NULL</code> value and columns containing the string literal <code class="literal">'NULL'</code>; both were represented as </p></div><pre class="programlisting"><field name="<em class="replaceable"><code>column_name</code></em>">NULL</field> </pre><p> Beginning with MySQL 5.0.26, the output when <code class="option">--xml</code> is used with <span><strong class="command">mysql</strong></span> matches that of <span><strong class="command">mysqldump <code class="option">--xml</code></strong></span>. See <a href="client-utility-programs.html#option_mysqldump_xml">the section of the Manual which discusses the <code class="option">--xml</code> option for <span><strong class="command">mysqldump</strong></span></a> for details. </p><p> Beginning with MySQL 5.0.40, the XML output also uses an XML namespace, as shown here: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql --xml -uroot -e "SHOW VARIABLES LIKE 'version%'"</code></strong> <?xml version="1.0"?> <resultset statement="SHOW VARIABLES LIKE 'version%'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="Variable_name">version</field> <field name="Value">5.0.40-debug</field> </row> <row> <field name="Variable_name">version_comment</field> <field name="Value">Source distribution</field> </row> <row> <field name="Variable_name">version_compile_machine</field> <field name="Value">i686</field> </row> <row> <field name="Variable_name">version_compile_os</field> <field name="Value">suse-linux-gnu</field> </row> </resultset> </pre><p> (See <a href="http://bugs.mysql.com/25946" target="_top">Bug#25946</a>.) </p></li></ul></div><p> You can also set the following variables by using <code class="option">--<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_connect_timeout"></a> <a class="indexterm" name="id2707436"></a> <a class="indexterm" name="id2707448"></a> <code class="literal">connect_timeout</code> </p><p> The number of seconds before connection timeout. (Default value is <code class="literal">0</code>.) </p></li><li><p><a name="option_mysql_max_alowed_packet"></a> <a class="indexterm" name="id2707483"></a> <code class="literal">max_allowed_packet</code> </p><p> The maximum packet length to send to or receive from the server. (Default value is 16MB.) </p></li><li><p><a name="option_mysql_max_join_size"></a> <a class="indexterm" name="id2707513"></a> <code class="literal">max_join_size</code> </p><p> The automatic limit for rows in a join when using <code class="option">--safe-updates</code>. (Default value is 1,000,000.) </p></li><li><p> <a class="indexterm" name="id2707544"></a> <code class="literal">net_buffer_length</code> </p><p> The buffer size for TCP/IP and socket communication. (Default value is 16KB.) </p></li><li><p><a name="option_mysql_select_limit"></a> <a class="indexterm" name="id2707573"></a> <code class="literal">select_limit</code> </p><p> The automatic limit for <code class="literal">SELECT</code> statements when using <code class="option">--safe-updates</code>. (Default value is 1,000.) </p></li></ul></div><p> It is also possible to set variables by using <code class="option">--set-variable=<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> or <code class="option">-O <em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax. <span class="emphasis"><em>This syntax is deprecated</em></span>. </p><a class="indexterm" name="id2707634"></a><a class="indexterm" name="id2707644"></a><a class="indexterm" name="id2707657"></a><a class="indexterm" name="id2707666"></a><a class="indexterm" name="id2707678"></a><a class="indexterm" name="id2707688"></a><a class="indexterm" name="id2707700"></a><p> On Unix, the <span><strong class="command">mysql</strong></span> client writes a record of executed statements to a history file. By default, the history file is named <code class="filename">.mysql_history</code> and is created in your home directory. To specify a different file, set the value of the <code class="literal">MYSQL_HISTFILE</code> environment variable. </p><p> If you do not want to maintain a history file, first remove <code class="filename">.mysql_history</code> if it exists, and then use either of the following techniques: </p><div class="itemizedlist"><ul type="disc"><li><p> Set the <code class="literal">MYSQL_HISTFILE</code> variable to <code class="filename">/dev/null</code>. To cause this setting to take effect each time you log in, put the setting in one of your shell's startup files. </p></li><li><p> Create <code class="filename">.mysql_history</code> as a symbolic link to <code class="filename">/dev/null</code>: </p><pre class="programlisting">shell> <strong class="userinput"><code>ln -s /dev/null $HOME/.mysql_history</code></strong> </pre><p> You need do this only once. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-commands"></a>7.7.2. <span><strong class="command">mysql</strong></span> Commands</h3></div></div></div><p> <span><strong class="command">mysql</strong></span> sends each SQL statement that you issue to the server to be executed. There is also a set of commands that <span><strong class="command">mysql</strong></span> itself interprets. For a list of these commands, type <code class="literal">help</code> or <code class="literal">\h</code> at the <code class="literal">mysql></code> prompt: </p><a class="indexterm" name="id2707858"></a><pre class="programlisting">mysql> <strong class="userinput"><code>help</code></strong> List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' </pre><p> Each command has both a long and short form. The long form is not case sensitive; the short form is. The long form can be followed by an optional semicolon terminator, but the short form should not. </p><p> The use of short-form commands within multi-line <code class="literal">/* ... */</code> comments is not supported. </p><p> If you provide an argument to the <code class="literal">help</code> command, <span><strong class="command">mysql</strong></span> uses it as a search string to access server-side help from the contents of the MySQL Reference Manual. For more information, see <a href="client-utility-programs.html#mysql-server-side-help" title="7.7.3. mysql Server-Side Help">Section 7.7.3, “<span><strong class="command">mysql</strong></span> Server-Side Help”</a>. </p><p> The <code class="literal">charset</code> command changes the default character set and issues a <code class="literal">SET NAMES</code> statement. This enables the character set to remain synchronized on the client and server if <span><strong class="command">mysql</strong></span> is run with auto-reconnect enabled (which is not recommended), because the changed character set is used for reconnects. This command was added in MySQL 5.0.25. </p><p> In the <code class="literal">delimiter</code> command, you should avoid the use of the backslash (“<span class="quote"><code class="literal">\</code></span>”) character because that is the escape character for MySQL. </p><p> The <span><strong class="command">edit</strong></span>, <span><strong class="command">nopager</strong></span>, <span><strong class="command">pager</strong></span>, and <span><strong class="command">system</strong></span> commands work only in Unix. </p><a class="indexterm" name="id2708030"></a><p> The <code class="literal">status</code> command provides some information about the connection and the server you are using. If you are running in <code class="option">--safe-updates</code> mode, <code class="literal">status</code> also prints the values for the <span><strong class="command">mysql</strong></span> variables that affect your queries. </p><p> To log queries and their output, use the <span><strong class="command">tee</strong></span> command. All the data displayed on the screen is appended into a given file. This can be very useful for debugging purposes also. You can enable this feature on the command line with the <code class="option">--tee</code> option, or interactively with the <span><strong class="command">tee</strong></span> command. The <span><strong class="command">tee</strong></span> file can be disabled interactively with the <span><strong class="command">notee</strong></span> command. Executing <span><strong class="command">tee</strong></span> again re-enables logging. Without a parameter, the previous file is used. Note that <span><strong class="command">tee</strong></span> flushes query results to the file after each statement, just before <span><strong class="command">mysql</strong></span> prints its next prompt. </p><p> By using the <code class="option">--pager</code> option, it is possible to browse or search query results in interactive mode with Unix programs such as <span><strong class="command">less</strong></span>, <span><strong class="command">more</strong></span>, or any other similar program. If you specify no value for the option, <span><strong class="command">mysql</strong></span> checks the value of the <code class="literal">PAGER</code> environment variable and sets the pager to that. Output paging can be enabled interactively with the <span><strong class="command">pager</strong></span> command and disabled with <span><strong class="command">nopager</strong></span>. The command takes an optional argument; if given, the paging program is set to that. With no argument, the pager is set to the pager that was set on the command line, or <code class="literal">stdout</code> if no pager was specified. </p><p> Output paging works only in Unix because it uses the <code class="literal">popen()</code> function, which does not exist on Windows. For Windows, the <span><strong class="command">tee</strong></span> option can be used instead to save query output, although this is not as convenient as <span><strong class="command">pager</strong></span> for browsing output in some situations. </p><p> Here are a few tips about the <span><strong class="command">pager</strong></span> command: </p><div class="itemizedlist"><ul type="disc"><li><p> You can use it to write to a file and the results go only to the file: </p><pre class="programlisting">mysql> <strong class="userinput"><code>pager cat > /tmp/log.txt</code></strong> </pre><p> You can also pass any options for the program that you want to use as your pager: </p><pre class="programlisting">mysql> <strong class="userinput"><code>pager less -n -i -S</code></strong> </pre></li><li><p> In the preceding example, note the <code class="option">-S</code> option. You may find it very useful for browsing wide query results. Sometimes a very wide result set is difficult to read on the screen. The <code class="option">-S</code> option to <span><strong class="command">less</strong></span> can make the result set much more readable because you can scroll it horizontally using the left-arrow and right-arrow keys. You can also use <code class="option">-S</code> interactively within <span><strong class="command">less</strong></span> to switch the horizontal-browse mode on and off. For more information, read the <span><strong class="command">less</strong></span> manual page: </p><pre class="programlisting">shell> <strong class="userinput"><code>man less</code></strong> </pre></li><li><p> You can specify very complex pager commands for handling query output: </p><pre class="programlisting">mysql> <strong class="userinput"><code>pager cat | tee /dr1/tmp/res.txt \</code></strong> <strong class="userinput"><code>| tee /dr2/tmp/res2.txt | less -n -i -S</code></strong> </pre><p> In this example, the command would send query results to two files in two different directories on two different filesystems mounted on <code class="filename">/dr1</code> and <code class="filename">/dr2</code>, yet still display the results onscreen via <span><strong class="command">less</strong></span>. </p></li></ul></div><p> You can also combine the <span><strong class="command">tee</strong></span> and <span><strong class="command">pager</strong></span> functions. Have a <span><strong class="command">tee</strong></span> file enabled and <span><strong class="command">pager</strong></span> set to <span><strong class="command">less</strong></span>, and you are able to browse the results using the <span><strong class="command">less</strong></span> program and still have everything appended into a file the same time. The difference between the Unix <span><strong class="command">tee</strong></span> used with the <span><strong class="command">pager</strong></span> command and the <span><strong class="command">mysql</strong></span> built-in <span><strong class="command">tee</strong></span> command is that the built-in <span><strong class="command">tee</strong></span> works even if you do not have the Unix <span><strong class="command">tee</strong></span> available. The built-in <span><strong class="command">tee</strong></span> also logs everything that is printed on the screen, whereas the Unix <span><strong class="command">tee</strong></span> used with <span><strong class="command">pager</strong></span> does not log quite that much. Additionally, <span><strong class="command">tee</strong></span> file logging can be turned on and off interactively from within <span><strong class="command">mysql</strong></span>. This is useful when you want to log some queries to a file, but not others. </p><a class="indexterm" name="id2708486"></a><p> The default <code class="literal">mysql></code> prompt can be reconfigured. The string for defining the prompt can contain the following special sequences: </p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><span class="bold"><strong>Option</strong></span></td><td><span class="bold"><strong>Description</strong></span></td></tr><tr><td><code class="literal">\v</code></td><td>The server version</td></tr><tr><td><code class="literal">\d</code></td><td>The default database</td></tr><tr><td><code class="literal">\h</code></td><td>The server host</td></tr><tr><td><code class="literal">\p</code></td><td>The current TCP/IP port or socket file</td></tr><tr><td><code class="literal">\u</code></td><td>Your username</td></tr><tr><td><code class="literal">\U</code></td><td>Your full <code class="literal"><em class="replaceable"><code>user_name</code></em>@<em class="replaceable"><code>host_name</code></em></code> account name</td></tr><tr><td><code class="literal">\\</code></td><td>A literal “<span class="quote"><code class="literal">\</code></span>” backslash character</td></tr><tr><td><code class="literal">\n</code></td><td>A newline character</td></tr><tr><td><code class="literal">\t</code></td><td>A tab character</td></tr><tr><td><code class="literal">\ </code></td><td>A space (a space follows the backslash)</td></tr><tr><td><code class="literal">\_</code></td><td>A space</td></tr><tr><td><code class="literal">\R</code></td><td>The current time, in 24-hour military time (0-23)</td></tr><tr><td><code class="literal">\r</code></td><td>The current time, standard 12-hour time (1-12)</td></tr><tr><td><code class="literal">\m</code></td><td>Minutes of the current time</td></tr><tr><td><code class="literal">\y</code></td><td>The current year, two digits</td></tr><tr><td><code class="literal">\Y</code></td><td>The current year, four digits</td></tr><tr><td><code class="literal">\D</code></td><td>The full current date</td></tr><tr><td><code class="literal">\s</code></td><td>Seconds of the current time</td></tr><tr><td><code class="literal">\w</code></td><td>The current day of the week in three-letter format (Mon, Tue, …)</td></tr><tr><td><code class="literal">\P</code></td><td>am/pm</td></tr><tr><td><code class="literal">\o</code></td><td>The current month in numeric format</td></tr><tr><td><code class="literal">\O</code></td><td>The current month in three-letter format (Jan, Feb, …)</td></tr><tr><td><code class="literal">\c</code></td><td>A counter that increments for each statement you issue</td></tr><tr><td><code class="literal">\l</code></td><td>The current delimiter. (New in 5.0.25)</td></tr><tr><td><code class="literal">\S</code></td><td>Semicolon</td></tr><tr><td><code class="literal">\'</code></td><td>Single quote</td></tr><tr><td><code class="literal">\"</code></td><td>Double quote</td></tr></tbody></table></div><p> “<span class="quote"><code class="literal">\</code></span>” followed by any other letter just becomes that letter. </p><p> If you specify the <code class="literal">prompt</code> command with no argument, <span><strong class="command">mysql</strong></span> resets the prompt to the default of <code class="literal">mysql></code>. </p><p> You can set the prompt in several ways: </p><div class="itemizedlist"><ul type="disc"><li><p> <span class="emphasis"><em>Use an environment variable.</em></span> You can set the <code class="literal">MYSQL_PS1</code> environment variable to a prompt string. For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>export MYSQL_PS1="(\u@\h) [\d]> "</code></strong> </pre></li><li><p> <span class="emphasis"><em>Use a command-line option.</em></span> You can set the <code class="option">--prompt</code> option on the command line to <span><strong class="command">mysql</strong></span>. For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql --prompt="(\u@\h) [\d]> "</code></strong> (user@host) [database]> </pre></li><li><p> <span class="emphasis"><em>Use an option file.</em></span> You can set the <code class="literal">prompt</code> option in the <code class="literal">[mysql]</code> group of any MySQL option file, such as <code class="filename">/etc/my.cnf</code> or the <code class="filename">.my.cnf</code> file in your home directory. For example: </p><pre class="programlisting">[mysql] prompt=(\\u@\\h) [\\d]>\\_ </pre><p> In this example, note that the backslashes are doubled. If you set the prompt using the <code class="literal">prompt</code> option in an option file, it is advisable to double the backslashes when using the special prompt options. There is some overlap in the set of allowable prompt options and the set of special escape sequences that are recognized in option files. (These sequences are listed in <a href="using-mysql-programs.html#option-files" title="4.3.2. Using Option Files">Section 4.3.2, “Using Option Files”</a>.) The overlap may cause you problems if you use single backslashes. For example, <code class="literal">\s</code> is interpreted as a space rather than as the current seconds value. The following example shows how to define a prompt within an option file to include the current time in <code class="literal">HH:MM:SS></code> format: </p><pre class="programlisting">[mysql] prompt="\\r:\\m:\\s> " </pre></li><li><p> <span class="emphasis"><em>Set the prompt interactively.</em></span> You can change your prompt interactively by using the <code class="literal">prompt</code> (or <code class="literal">\R</code>) command. For example: </p><pre class="programlisting">mysql> <strong class="userinput"><code>prompt (\u@\h) [\d]>\_</code></strong> PROMPT set to '(\u@\h) [\d]>\_' (<em class="replaceable"><code>user</code></em>@<em class="replaceable"><code>host</code></em>) [<em class="replaceable"><code>database</code></em>]> (<em class="replaceable"><code>user</code></em>@<em class="replaceable"><code>host</code></em>) [<em class="replaceable"><code>database</code></em>]> prompt Returning to default PROMPT of mysql> mysql><strong class="userinput"><code></code></strong> </pre></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-server-side-help"></a>7.7.3. <span><strong class="command">mysql</strong></span> Server-Side Help</h3></div></div></div><pre class="programlisting">mysql> <strong class="userinput"><code>help <em class="replaceable"><code>search_string</code></em></code></strong> </pre><p> If you provide an argument to the <code class="literal">help</code> command, <span><strong class="command">mysql</strong></span> uses it as a search string to access server-side help from the contents of the MySQL Reference Manual. The proper operation of this command requires that the help tables in the <code class="literal">mysql</code> database be initialized with help topic information (see <a href="server-administration.html#server-side-help-support" title="5.2.8. Server-Side Help">Section 5.2.8, “Server-Side Help”</a>). </p><p> If there is no match for the search string, the search fails: </p><pre class="programlisting">mysql> <strong class="userinput"><code>help me</code></strong> Nothing found Please try to run 'help contents' for a list of all accessible topics </pre><p> Use <span><strong class="command">help contents</strong></span> to see a list of the help categories: </p><pre class="programlisting">mysql> <strong class="userinput"><code>help contents</code></strong> You asked for help about help category: "Contents" For more information, type 'help <item>', where <item> is one of the following categories: Account Management Administration Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Language Structure Storage Engines Stored Routines Table Maintenance Transactions Triggers </pre><p> If the search string matches multiple items, <span><strong class="command">mysql</strong></span> shows a list of matching topics: </p><pre class="programlisting">mysql> <strong class="userinput"><code>help logs</code></strong> Many help items for your request exist. To make a more specific request, please type 'help <item>', where <item> is one of the following topics: SHOW SHOW BINARY LOGS SHOW ENGINE SHOW LOGS </pre><p> Use a topic as the search string to see the help entry for that topic: </p><pre class="programlisting">mysql> <strong class="userinput"><code>help show binary logs</code></strong> Name: 'SHOW BINARY LOGS' Description: Syntax: SHOW BINARY LOGS SHOW MASTER LOGS Lists the binary log files on the server. This statement is used as part of the procedure described in [purge-master-logs], that shows how to determine which logs can be purged. mysql> SHOW BINARY LOGS; +---------------+-----------+ | Log_name | File_size | +---------------+-----------+ | binlog.000015 | 724935 | | binlog.000016 | 733481 | +---------------+-----------+ </pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="batch-commands"></a>7.7.4. Executing SQL Statements from a Text File</h3></div></div></div><a class="indexterm" name="id2709415"></a><a class="indexterm" name="id2709424"></a><a class="indexterm" name="id2709437"></a><a class="indexterm" name="id2709449"></a><a class="indexterm" name="id2709462"></a><a class="indexterm" name="id2709474"></a><a class="indexterm" name="id2709484"></a><a class="indexterm" name="id2709493"></a><a class="indexterm" name="id2709503"></a><p> The <span><strong class="command">mysql</strong></span> client typically is used interactively, like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> However, it is also possible to put your SQL statements in a file and then tell <span><strong class="command">mysql</strong></span> to read its input from that file. To do so, create a text file <em class="replaceable"><code>text_file</code></em> that contains the statements you wish to execute. Then invoke <span><strong class="command">mysql</strong></span> as shown here: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em> < <em class="replaceable"><code>text_file</code></em></code></strong> </pre><p> If you place a <code class="literal">USE <em class="replaceable"><code>db_name</code></em></code> statement as the first statement in the file, it is unnecessary to specify the database name on the command line: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql < text_file</code></strong> </pre><p> If you are already running <span><strong class="command">mysql</strong></span>, you can execute an SQL script file using the <code class="literal">source</code> command or <code class="literal">\.</code> command: </p><pre class="programlisting">mysql> <strong class="userinput"><code>source <em class="replaceable"><code>file_name</code></em></code></strong> mysql> <strong class="userinput"><code>\. <em class="replaceable"><code>file_name</code></em></code></strong> </pre><p> Sometimes you may want your script to display progress information to the user. For this you can insert statements like this: </p><pre class="programlisting">SELECT '<info_to_display>' AS ' '; </pre><p> The statement shown outputs <code class="literal"><info_to_display></code>. </p><p> For more information about batch mode, see <a href="tutorial.html#batch-mode" title="3.5. Using mysql in Batch Mode">Section 3.5, “Using <span><strong class="command">mysql</strong></span> in Batch Mode”</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-tips"></a>7.7.5. <span><strong class="command">mysql</strong></span> Tips</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="client-utility-programs.html#vertical-query-results">7.7.5.1. Displaying Query Results Vertically</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#safe-updates">7.7.5.2. Using the <code class="option">--safe-updates</code> Option</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-reconnect">7.7.5.3. Disabling <span><strong class="command">mysql</strong></span> Auto-Reconnect</a></span></dt></dl></div><p> This section describes some techniques that can help you use <span><strong class="command">mysql</strong></span> more effectively. </p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="vertical-query-results"></a>7.7.5.1. Displaying Query Results Vertically</h4></div></div></div><p> Some query results are much more readable when displayed vertically, instead of in the usual horizontal table format. Queries can be displayed vertically by terminating the query with \G instead of a semicolon. For example, longer text values that include newlines often are much easier to read with vertical output: </p><pre class="programlisting">mysql> <strong class="userinput"><code>SELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\G</code></strong> *************************** 1. row *************************** msg_nro: 3068 date: 2000-03-01 23:29:50 time_zone: +0200 mail_from: Monty reply: monty@no.spam.com mail_to: "Thimble Smith" <tim@no.spam.com> sbj: UTF-8 txt: >>>>> "Thimble" == Thimble Smith writes: Thimble> Hi. I think this is a good idea. Is anyone familiar Thimble> with UTF-8 or Unicode? Otherwise, I'll put this on my Thimble> TODO list and see what happens. Yes, please do that. Regards, Monty file: inbox-jani-1 hash: 190402944 1 row in set (0.09 sec) </pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="safe-updates"></a>7.7.5.2. Using the <code class="option">--safe-updates</code> Option</h4></div></div></div><a class="indexterm" name="id2709767"></a><p> For beginners, a useful startup option is <code class="option">--safe-updates</code> (or <code class="option">--i-am-a-dummy</code>, which has the same effect). It is helpful for cases when you might have issued a <code class="literal">DELETE FROM <em class="replaceable"><code>tbl_name</code></em></code> statement but forgotten the <code class="literal">WHERE</code> clause. Normally, such a statement deletes all rows from the table. With <code class="option">--safe-updates</code>, you can delete rows only by specifying the key values that identify them. This helps prevent accidents. </p><p> When you use the <code class="option">--safe-updates</code> option, <span><strong class="command">mysql</strong></span> issues the following statement when it connects to the MySQL server: </p><pre class="programlisting">SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=1000, SQL_MAX_JOIN_SIZE=1000000; </pre><p> See <a href="sql-syntax.html#set-option" title="12.5.3. SET Syntax">Section 12.5.3, “<code class="literal">SET</code> Syntax”</a>. </p><p> The <code class="literal">SET</code> statement has the following effects: </p><div class="itemizedlist"><ul type="disc"><li><p> You are not allowed to execute an <code class="literal">UPDATE</code> or <code class="literal">DELETE</code> statement unless you specify a key constraint in the <code class="literal">WHERE</code> clause or provide a <code class="literal">LIMIT</code> clause (or both). For example: </p><pre class="programlisting">UPDATE <em class="replaceable"><code>tbl_name</code></em> SET <em class="replaceable"><code>not_key_column</code></em>=<em class="replaceable"><code>val</code></em> WHERE <em class="replaceable"><code>key_column</code></em>=<em class="replaceable"><code>val</code></em>; UPDATE <em class="replaceable"><code>tbl_name</code></em> SET <em class="replaceable"><code>not_key_column</code></em>=<em class="replaceable"><code>val</code></em> LIMIT 1; </pre></li><li><p> The server limits all large <code class="literal">SELECT</code> results to 1,000 rows unless the statement includes a <code class="literal">LIMIT</code> clause. </p></li><li><p> The server aborts multiple-table <code class="literal">SELECT</code> statements that probably need to examine more than 1,000,000 row combinations. </p></li></ul></div><p> To specify limits different from 1,000 and 1,000,000, you can override the defaults by using the <code class="option">--select_limit</code> and <code class="option">--max_join_size</code> options: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql --safe-updates --select_limit=500 --max_join_size=10000</code></strong> </pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="mysql-reconnect"></a>7.7.5.3. Disabling <span><strong class="command">mysql</strong></span> Auto-Reconnect</h4></div></div></div><p> If the <span><strong class="command">mysql</strong></span> client loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again. However, even if <span><strong class="command">mysql</strong></span> succeeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user-defined and session variables. Also, any current transaction rolls back. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it: </p><pre class="programlisting">mysql> <strong class="userinput"><code>SET @a=1;</code></strong> Query OK, 0 rows affected (0.05 sec) mysql> <strong class="userinput"><code>INSERT INTO t VALUES(@a);</code></strong> ERROR 2006: MySQL server has gone away No connection. Trying to reconnect... Connection id: 1 Current database: test Query OK, 1 row affected (1.30 sec) mysql> <strong class="userinput"><code>SELECT * FROM t;</code></strong> +------+ | a | +------+ | NULL | +------+ 1 row in set (0.05 sec) </pre><p> The <code class="literal">@a</code> user variable has been lost with the connection, and after the reconnection it is undefined. If it is important to have <span><strong class="command">mysql</strong></span> terminate with an error if the connection has been lost, you can start the <span><strong class="command">mysql</strong></span> client with the <code class="option">--skip-reconnect</code> option. </p><p> For more information about auto-reconnect and its effect on state information when a reconnection occurs, see <a href="apis.html#auto-reconnect" title="23.2.13. Controlling Automatic Reconnect Behavior">Section 23.2.13, “Controlling Automatic Reconnect Behavior”</a>. </p></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlaccess"></a>7.8. <span><strong class="command">mysqlaccess</strong></span> — Client for Checking Access Privileges</h2></div></div></div><p> <span><strong class="command">mysqlaccess</strong></span> is a diagnostic tool that Yves Carlier has provided for the MySQL distribution. It checks the access privileges for a hostname, username, and database combination. Note that <span><strong class="command">mysqlaccess</strong></span> checks access using only the <code class="literal">user</code>, <code class="literal">db</code>, and <code class="literal">host</code> tables. It does not check table, column, or routine privileges specified in the <code class="literal">tables_priv</code>, <code class="literal">columns_priv</code>, or <code class="literal">procs_priv</code> tables. </p><p> Invoke <span><strong class="command">mysqlaccess</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlaccess [<em class="replaceable"><code>host_name</code></em> [<em class="replaceable"><code>user_name</code></em> [<em class="replaceable"><code>db_name</code></em>]]] [<em class="replaceable"><code>options</code></em>]</code></strong> </pre><p> <span><strong class="command">mysqlaccess</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlaccess_help"></a> <a class="indexterm" name="id2710230"></a> <a class="indexterm" name="id2710243"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlaccess_brief"></a> <a class="indexterm" name="id2710275"></a> <a class="indexterm" name="id2710288"></a> <code class="option">--brief</code>, <code class="option">-b</code> </p><p> Generate reports in single-line tabular format. </p></li><li><p><a name="option_mysqlaccess_commit"></a> <a class="indexterm" name="id2710320"></a> <a class="indexterm" name="id2710333"></a> <code class="option">--commit</code> </p><p> Copy the new access privileges from the temporary tables to the original grant tables. The grant tables must be flushed for the new privileges to take effect. (For example, execute a <span><strong class="command">mysqladmin reload</strong></span> command.) </p></li><li><p><a name="option_mysqlaccess_copy"></a> <a class="indexterm" name="id2710372"></a> <a class="indexterm" name="id2710384"></a> <code class="option">--copy</code> </p><p> Reload the temporary grant tables from original ones. </p></li><li><p><a name="option_mysqlaccess_db"></a> <a class="indexterm" name="id2710414"></a> <a class="indexterm" name="id2710426"></a> <code class="option">--db=<em class="replaceable"><code>db_name</code></em></code>, <code class="option">-d <em class="replaceable"><code>db_name</code></em></code> </p><p> Specify the database name. </p></li><li><p><a name="option_mysqlaccess_debug"></a> <a class="indexterm" name="id2710463"></a> <a class="indexterm" name="id2710476"></a> <code class="option">--debug=<em class="replaceable"><code>N</code></em></code> </p><p> Specify the debug level. <em class="replaceable"><code>N</code></em> can be an integer from 0 to 3. </p></li><li><p><a name="option_mysqlaccess_host"></a> <a class="indexterm" name="id2710511"></a> <a class="indexterm" name="id2710524"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> The hostname to use in the access privileges. </p></li><li><p><a name="option_mysqlaccess_howto"></a> <a class="indexterm" name="id2710561"></a> <a class="indexterm" name="id2710574"></a> <code class="option">--howto</code> </p><p> Display some examples that show how to use <span><strong class="command">mysqlaccess</strong></span>. </p></li><li><p><a name="option_mysqlaccess_old_server"></a> <a class="indexterm" name="id2710610"></a> <a class="indexterm" name="id2710622"></a> <code class="option">--old_server</code> </p><p> Assume that the server is an old MySQL server (before MySQL 3.21) that does not yet know how to handle full <code class="literal">WHERE</code> clauses. </p></li><li><p><a name="option_mysqlaccess_password"></a> <a class="indexterm" name="id2710659"></a> <a class="indexterm" name="id2710672"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlaccess_plan"></a> <a class="indexterm" name="id2710735"></a> <a class="indexterm" name="id2710748"></a> <code class="option">--plan</code> </p><p> Display suggestions and ideas for future releases. </p></li><li><p><a name="option_mysqlaccess_preview"></a> <a class="indexterm" name="id2710777"></a> <a class="indexterm" name="id2710790"></a> <code class="option">--preview</code> </p><p> Show the privilege differences after making changes to the temporary grant tables. </p></li><li><p><a name="option_mysqlaccess_relnotes"></a> <a class="indexterm" name="id2710820"></a> <a class="indexterm" name="id2710833"></a> <code class="option">--relnotes</code> </p><p> Display the release notes. </p></li><li><p><a name="option_mysqlaccess_rhost"></a> <a class="indexterm" name="id2710862"></a> <a class="indexterm" name="id2710874"></a> <code class="option">--rhost=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-H <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysqlaccess_rollback"></a> <a class="indexterm" name="id2710913"></a> <a class="indexterm" name="id2710925"></a> <code class="option">--rollback</code> </p><p> Undo the most recent changes to the temporary grant tables. </p></li><li><p><a name="option_mysqlaccess_spassword"></a> <a class="indexterm" name="id2710955"></a> <a class="indexterm" name="id2710968"></a> <code class="option">--spassword[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-P[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server as the superuser. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlaccess_superuser"></a> <a class="indexterm" name="id2711032"></a> <a class="indexterm" name="id2711044"></a> <code class="option">--superuser=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-U <em class="replaceable"><code>user_name</code></em></code> </p><p> Specify the username for connecting as the superuser. </p></li><li><p><a name="option_mysqlaccess_table"></a> <a class="indexterm" name="id2711083"></a> <a class="indexterm" name="id2711096"></a> <code class="option">--table</code>, <code class="option">-t</code> </p><p> Generate reports in table format. </p></li><li><p><a name="option_mysqlaccess_user"></a> <a class="indexterm" name="id2711128"></a> <a class="indexterm" name="id2711140"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The username to use in the access privileges. </p></li><li><p><a name="option_mysqlaccess_version"></a> <a class="indexterm" name="id2711178"></a> <a class="indexterm" name="id2711191"></a> <code class="option">--version</code>, <code class="option">-v</code> </p><p> Display version information and exit. </p></li></ul></div><p> If your MySQL distribution is installed in some non-standard location, you must change the location where <span><strong class="command">mysqlaccess</strong></span> expects to find the <span><strong class="command">mysql</strong></span> client. Edit the <code class="filename">mysqlaccess</code> script at approximately line 18. Search for a line that looks like this: </p><pre class="programlisting">$MYSQL = '/usr/local/bin/mysql'; # path to mysql executable </pre><p> Change the path to reflect the location where <span><strong class="command">mysql</strong></span> actually is stored on your system. If you do not do this, a <code class="literal">Broken pipe</code> error will occur when you run <span><strong class="command">mysqlaccess</strong></span>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqladmin"></a>7.9. <span><strong class="command">mysqladmin</strong></span> — Client for Administering a MySQL Server</h2></div></div></div><p> <span><strong class="command">mysqladmin</strong></span> is a client for performing administrative operations. You can use it to check the server's configuration and current status, to create and drop databases, and more. </p><p> Invoke <span><strong class="command">mysqladmin</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqladmin [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>command</code></em> [<em class="replaceable"><code>command-arg</code></em>] [<em class="replaceable"><code>command</code></em> [<em class="replaceable"><code>command-arg</code></em>]] ...</code></strong> </pre><p> <span><strong class="command">mysqladmin</strong></span> supports the commands described in the following list. Some of the commands take an argument following the command name. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="command_mysqladmin_db_name"></a> <code class="literal">create <em class="replaceable"><code>db_name</code></em></code> </p><p> Create a new database named <em class="replaceable"><code>db_name</code></em>. </p></li><li><p><a name="command_mysqladmin_debug"></a> <code class="literal">debug</code> </p><p> Tell the server to write debug information to the error log. </p></li><li><p><a name="command_mysqladmin_drop"></a> <code class="literal">drop <em class="replaceable"><code>db_name</code></em></code> </p><p> Delete the database named <em class="replaceable"><code>db_name</code></em> and all its tables. </p></li><li><p><a name="command_mysqladmin_extended-status"></a> <code class="literal">extended-status</code> </p><p> Display the server status variables and their values. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on using server status variables, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="command_mysqladmin_flush-hosts"></a> <code class="literal">flush-hosts</code> </p><p> Flush all information in the host cache. </p></li><li><p><a name="command_mysqladmin_flush-logs"></a> <code class="literal">flush-logs</code> </p><p> Flush all logs. </p></li><li><p><a name="command_mysqladmin_flush-privileges"></a> <code class="literal">flush-privileges</code> </p><p> Reload the grant tables (same as <code class="literal">reload</code>). </p></li><li><p><a name="command_mysqladmin_flush-status"></a> <code class="literal">flush-status</code> </p><p> Clear status variables. </p></li><li><p><a name="command_mysqladmin_flush-tables"></a> <code class="literal">flush-tables</code> </p><p> Flush all tables. </p></li><li><p><a name="command_mysqladmin_flush-threads"></a> <code class="literal">flush-threads</code> </p><p> Flush the thread cache. </p></li><li><p><a name="command_mysqladmin_kill"></a> <code class="literal">kill <em class="replaceable"><code>id</code></em>,<em class="replaceable"><code>id</code></em>,...</code> </p><p> Kill server threads. If multiple thread ID values are given, there must be no spaces in the list. </p></li><li><p><a name="command_mysqladmin_old-password"></a> <code class="literal">old-password <em class="replaceable"><code>new-password</code></em></code> </p><p> This is like the <code class="literal">password</code> command but stores the password using the old (pre-4.1) password-hashing format. (See <a href="server-administration.html#password-hashing" title="5.7.9. Password Hashing as of MySQL 4.1">Section 5.7.9, “Password Hashing as of MySQL 4.1”</a>.) </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on the security implications of using the <code class="literal">old-password</code> command, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="command_mysqladmin_password"></a> <code class="literal">password <em class="replaceable"><code>new-password</code></em></code> </p><p> Set a new password. This changes the password to <em class="replaceable"><code>new-password</code></em> for the account that you use with <span><strong class="command">mysqladmin</strong></span> for connecting to the server. Thus, the next time you invoke <span><strong class="command">mysqladmin</strong></span> (or any other client program) using the same account, you will need to specify the new password. </p><p> If the <em class="replaceable"><code>new-password</code></em> value contains spaces or other characters that are special to your command interpreter, you need to enclose it within quotes. On Windows, be sure to use double quotes rather than single quotes; single quotes are not stripped from the password, but rather are interpreted as part of the password. For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqladmin password "my new password"</code></strong> </pre></li><li><p><a name="command_mysqladmin_ping"></a> <code class="literal">ping</code> </p><p> Check whether the server is alive. The return status from <span><strong class="command">mysqladmin</strong></span> is 0 if the server is running, 1 if it is not. This is 0 even in case of an error such as <code class="literal">Access denied</code>, because this means that the server is running but refused the connection, which is different from the server not running. </p></li><li><p><a name="command_mysqladmin_processlist"></a> <code class="literal">processlist</code> </p><p> Show a list of active server threads. This is like the output of the <code class="literal">SHOW PROCESSLIST</code> statement. If the <code class="option">--verbose</code> option is given, the output is like that of <code class="literal">SHOW FULL PROCESSLIST</code>. (See <a href="sql-syntax.html#show-processlist" title="12.5.4.21. SHOW PROCESSLIST Syntax">Section 12.5.4.21, “<code class="literal">SHOW PROCESSLIST</code> Syntax”</a>.) </p></li><li><p><a name="command_mysqladmin_reload"></a> <code class="literal">reload</code> </p><p> Reload the grant tables. </p></li><li><p><a name="command_mysqladmin_refresh"></a> <code class="literal">refresh</code> </p><p> Flush all tables and close and open log files. </p></li><li><p><a name="command_mysqladmin_shutdown"></a> <code class="literal">shutdown</code> </p><p> Stop the server. </p></li><li><p><a name="command_mysqladmin_start-slave"></a> <code class="literal">start-slave</code> </p><p> Start replication on a slave server. </p></li><li><p><a name="command_mysqladmin_status"></a> <code class="literal">status</code> </p><p> Display a short server status message. </p></li><li><p><a name="command_mysqladmin_stop-slave"></a> <code class="literal">stop-slave</code> </p><p> Stop replication on a slave server. </p></li><li><p><a name="command_mysqladmin_variables"></a> <code class="literal">variables</code> </p><p> Display the server system variables and their values. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on using server system variables, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="command_mysqladmin_version"></a> <code class="literal">version</code> </p><p> Display version information from the server. </p></li></ul></div><p> All commands can be shortened to any unique prefix. For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqladmin proc stat</code></strong> +----+-------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-------+-----------+----+---------+------+-------+------------------+ | 51 | monty | localhost | | Query | 0 | | show processlist | +----+-------+-----------+----+---------+------+-------+------------------+ Uptime: 1473624 Threads: 1 Questions: 39487 Slow queries: 0 Opens: 541 Flush tables: 1 Open tables: 19 Queries per second avg: 0.0268 </pre><a class="indexterm" name="id2712023"></a><p> The <span><strong class="command">mysqladmin status</strong></span> command result displays the following values: </p><div class="itemizedlist"><ul type="disc"><li><p> <a class="indexterm" name="id2712053"></a> <code class="literal">Uptime</code> </p><p> The number of seconds the MySQL server has been running. </p></li><li><p> <a class="indexterm" name="id2712079"></a> <code class="literal">Threads</code> </p><p> The number of active threads (clients). </p></li><li><p> <a class="indexterm" name="id2712104"></a> <code class="literal">Questions</code> </p><p> The number of questions (queries) from clients since the server was started. </p></li><li><p> <a class="indexterm" name="id2712130"></a> <code class="literal">Slow queries</code> </p><p> The number of queries that have taken more than <code class="literal">long_query_time</code> seconds. See <a href="server-administration.html#slow-query-log" title="5.10.4. The Slow Query Log">Section 5.10.4, “The Slow Query Log”</a>. </p></li><li><p> <a class="indexterm" name="id2712168"></a> <code class="literal">Opens</code> </p><p> The number of tables the server has opened. </p></li><li><p> <a class="indexterm" name="id2712194"></a> <a class="indexterm" name="id2712203"></a> <code class="literal">Flush tables</code> </p><p> The number of <code class="literal">flush-*</code>, <code class="literal">refresh</code>, and <code class="literal">reload</code> commands the server has executed. </p></li><li><p> <a class="indexterm" name="id2712250"></a> <code class="literal">Open tables</code> </p><p> The number of tables that currently are open. </p></li><li><p> <a class="indexterm" name="id2712276"></a> <code class="literal">Memory in use</code> </p><p> The amount of memory allocated directly by <span><strong class="command">mysqld</strong></span>. This value is displayed only when MySQL has been compiled with <code class="option">--with-debug=full</code>. </p></li><li><p> <a class="indexterm" name="id2712313"></a> <code class="literal">Maximum memory used</code> </p><p> The maximum amount of memory allocated directly by <span><strong class="command">mysqld</strong></span>. This value is displayed only when MySQL has been compiled with <code class="option">--with-debug=full</code>. </p></li></ul></div><p> If you execute <span><strong class="command">mysqladmin shutdown</strong></span> when connecting to a local server using a Unix socket file, <span><strong class="command">mysqladmin</strong></span> waits until the server's process ID file has been removed, to ensure that the server has stopped properly. </p><a class="indexterm" name="id2712366"></a><a class="indexterm" name="id2712376"></a><a class="indexterm" name="id2712388"></a><a class="indexterm" name="id2712404"></a><p> <span><strong class="command">mysqladmin</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqladmin_help"></a> <a class="indexterm" name="id2712435"></a> <a class="indexterm" name="id2712448"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqladmin_character-sets-dir"></a> <a class="indexterm" name="id2712480"></a> <a class="indexterm" name="id2712493"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqladmin_compress"></a> <a class="indexterm" name="id2712531"></a> <a class="indexterm" name="id2712543"></a> <code class="option">--compress</code>, <code class="option">-C</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysqladmin_count"></a> <a class="indexterm" name="id2712577"></a> <a class="indexterm" name="id2712589"></a> <code class="option">--count=<em class="replaceable"><code>N</code></em></code>, <code class="option">-c <em class="replaceable"><code>N</code></em></code> </p><p> The number of iterations to make for repeated command execution. This works only with the <code class="option">--sleep</code> option. </p></li><li><p><a name="option_mysqladmin_debug"></a> <a class="indexterm" name="id2712632"></a> <a class="indexterm" name="id2712644"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. The default is <code class="literal">'d:t:o,/tmp/mysqladmin.trace'</code>. </p></li><li><p><a name="option_mysqladmin_default-character-set"></a> <a class="indexterm" name="id2712706"></a> <a class="indexterm" name="id2712719"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqladmin_force"></a> <a class="indexterm" name="id2712760"></a> <a class="indexterm" name="id2712773"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Do not ask for confirmation for the <code class="literal">drop <em class="replaceable"><code>db_name</code></em></code> command. With multiple commands, continue even if an error occurs. </p></li><li><p><a name="option_mysqladmin_host"></a> <a class="indexterm" name="id2712815"></a> <a class="indexterm" name="id2712827"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysqladmin_password"></a> <a class="indexterm" name="id2712865"></a> <a class="indexterm" name="id2712878"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqladmin_port"></a> <a class="indexterm" name="id2712950"></a> <a class="indexterm" name="id2712963"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysqladmin_protocol"></a> <a class="indexterm" name="id2713000"></a> <a class="indexterm" name="id2713013"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqladmin_relative"></a> <a class="indexterm" name="id2713043"></a> <a class="indexterm" name="id2713055"></a> <code class="option">--relative</code>, <code class="option">-r</code> </p><p> Show the difference between the current and previous values when used with the <code class="option">--sleep</code> option. Currently, this option works only with the <code class="literal">extended-status</code> command. </p></li><li><p><a name="option_mysqladmin_silent"></a> <a class="indexterm" name="id2713100"></a> <a class="indexterm" name="id2713112"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Exit silently if a connection to the server cannot be established. </p></li><li><p><a name="option_mysqladmin_sleep"></a> <a class="indexterm" name="id2713146"></a> <a class="indexterm" name="id2713158"></a> <code class="option">--sleep=<em class="replaceable"><code>delay</code></em></code>, <code class="option">-i <em class="replaceable"><code>delay</code></em></code> </p><p> Execute commands repeatedly, sleeping for <em class="replaceable"><code>delay</code></em> seconds in between. The <code class="option">--count</code> option determines the number of iterations. </p></li><li><p><a name="option_mysqladmin_socket"></a> <a class="indexterm" name="id2713205"></a> <a class="indexterm" name="id2713218"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqladmin_ssl"></a> <a class="indexterm" name="id2713263"></a> <a class="indexterm" name="id2713275"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysqladmin_user"></a> <a class="indexterm" name="id2713315"></a> <a class="indexterm" name="id2713327"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysqladmin_verbose"></a> <a class="indexterm" name="id2713365"></a> <a class="indexterm" name="id2713378"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_mysqladmin_version"></a> <a class="indexterm" name="id2713411"></a> <a class="indexterm" name="id2713424"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li><li><p><a name="option_mysqladmin_vertical"></a> <a class="indexterm" name="id2713456"></a> <a class="indexterm" name="id2713469"></a> <code class="option">--vertical</code>, <code class="option">-E</code> </p><p> Print output vertically. This is similar to <code class="option">--relative</code>, but prints output vertically. </p></li><li><p><a name="option_mysqladmin_wait"></a> <a class="indexterm" name="id2713506"></a> <a class="indexterm" name="id2713518"></a> <code class="option">--wait[=<em class="replaceable"><code>count</code></em>]</code>, <code class="option">-w[<em class="replaceable"><code>count</code></em>]</code> </p><p> If the connection cannot be established, wait and retry instead of aborting. If a <em class="replaceable"><code>count</code></em> value is given, it indicates the number of times to retry. The default is one time. </p></li></ul></div><p> You can also set the following variables by using <code class="option">--<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqladmin_connect_timeout"></a> <a class="indexterm" name="id2713582"></a> <a class="indexterm" name="id2713591"></a> <code class="literal">connect_timeout</code> </p><p> The maximum number of seconds before connection timeout. The default value is 43200 (12 hours). </p></li><li><p><a name="option_mysqladmin_shutdown_timeout"></a> <a class="indexterm" name="id2713624"></a> <a class="indexterm" name="id2713633"></a> <code class="literal">shutdown_timeout</code> </p><p> The maximum number of seconds to wait for server shutdown. The default value is 3600 (1 hour). </p></li></ul></div><p> It is also possible to set variables by using <code class="option">--set-variable=<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> or <code class="option">-O <em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax. <span class="emphasis"><em>This syntax is deprecated</em></span>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlbinlog"></a>7.10. <span><strong class="command">mysqlbinlog</strong></span> — Utility for Processing Binary Log Files</h2></div></div></div><p> The binary log files that the server generates are written in binary format. To examine these files in text format, use the <span><strong class="command">mysqlbinlog</strong></span> utility. You can also use <span><strong class="command">mysqlbinlog</strong></span> to read relay log files written by a slave server in a replication setup. Relay logs have the same format as binary log files. </p><p> Invoke <span><strong class="command">mysqlbinlog</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>log_file</code></em> ...</code></strong> </pre><p> For example, to display the contents of the binary log file named <code class="filename">binlog.000003</code>, use this command: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.0000003</code></strong> </pre><p> The output includes all events contained in <code class="filename">binlog.000003</code>. Event information includes the statement executed, the time the statement took, the thread ID of the client that issued it, the timestamp when it was executed, and so forth. </p><p> The output from <span><strong class="command">mysqlbinlog</strong></span> can be re-executed (for example, by using it as input to <span><strong class="command">mysql</strong></span>) to reapply the statements in the log. This is useful for recovery operations after a server crash. For other usage examples, see the discussion later in this section. </p><p> Normally, you use <span><strong class="command">mysqlbinlog</strong></span> to read binary log files directly and apply them to the local MySQL server. It is also possible to read binary logs from a remote server by using the <code class="option">--read-from-remote-server</code> option. When you read remote binary logs, the connection parameter options can be given to indicate how to connect to the server. These options are <code class="option">--host</code>, <code class="option">--password</code>, <code class="option">--port</code>, <code class="option">--protocol</code>, <code class="option">--socket</code>, and <code class="option">--user</code>; they are ignored except when you also use the <code class="option">--read-from-remote-server</code> option. </p><p> Binary logs and relay logs are discussed further in <a href="server-administration.html#binary-log" title="5.10.3. The Binary Log">Section 5.10.3, “The Binary Log”</a>, and <a href="replication.html#slave-logs" title="15.4.2. Replication Relay and Status Files">Section 15.4.2, “Replication Relay and Status Files”</a>. </p><p> <span><strong class="command">mysqlbinlog</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlbinlog_help"></a> <a class="indexterm" name="id2713890"></a> <a class="indexterm" name="id2713902"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlbinlog_character-sets-dir"></a> <a class="indexterm" name="id2713935"></a> <a class="indexterm" name="id2713947"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlbinlog_database"></a> <a class="indexterm" name="id2713985"></a> <a class="indexterm" name="id2713997"></a> <code class="option">--database=<em class="replaceable"><code>db_name</code></em></code>, <code class="option">-d <em class="replaceable"><code>db_name</code></em></code> </p><p> List entries for just this database (local log only). You can only specify one database with this option - if you specify multiple <code class="option">--database</code> options, only the last one is used. This option forces <span><strong class="command">mysqlbinlog</strong></span> to output entries from the binary log where the default database (that is, the one selected by <code class="literal">USE</code>) is <em class="replaceable"><code>db_name</code></em>. Note that this does not replicate cross-database statements such as <code class="literal">UPDATE <em class="replaceable"><code>some_db.some_table</code></em> SET foo='bar'</code> while having selected a different database or no database. </p></li><li><p><a name="option_mysqlbinlog_debug"></a> <a class="indexterm" name="id2714073"></a> <a class="indexterm" name="id2714086"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. A typical <em class="replaceable"><code>debug_options</code></em> string is often <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_mysqlbinlog_disable-log-bin"></a> <a class="indexterm" name="id2714140"></a> <a class="indexterm" name="id2714153"></a> <code class="option">--disable-log-bin</code>, <code class="option">-D</code> </p><p> Disable binary logging. This is useful for avoiding an endless loop if you use the <code class="option">--to-last-log</code> option and are sending the output to the same MySQL server. This option also is useful when restoring after a crash to avoid duplication of the statements you have logged. </p><p> This option requires that you have the <code class="literal">SUPER</code> privilege. It causes <span><strong class="command">mysqlbinlog</strong></span> to include a <code class="literal">SET SQL_LOG_BIN=0</code> statement in its output to disable binary logging of the remaining output. The <code class="literal">SET</code> statement is ineffective unless you have the <code class="literal">SUPER</code> privilege. </p></li><li><p><a name="option_mysqlbinlog_force-read"></a> <a class="indexterm" name="id2714232"></a> <a class="indexterm" name="id2714245"></a> <code class="option">--force-read</code>, <code class="option">-f</code> </p><p> With this option, if <span><strong class="command">mysqlbinlog</strong></span> reads a binary log event that it does not recognize, it prints a warning, ignores the event, and continues. Without this option, <span><strong class="command">mysqlbinlog</strong></span> stops if it reads such an event. </p></li><li><p><a name="option_mysqlbinlog_hexdump"></a> <a class="indexterm" name="id2714293"></a> <a class="indexterm" name="id2714306"></a> <code class="option">--hexdump</code>, <code class="option">-H</code> </p><p> Display a hex dump of the log in comments. This output can be helpful for replication debugging. Hex dump format is discussed later in this section. This option was added in MySQL 5.0.16. </p></li><li><p><a name="option_mysqlbinlog_host"></a> <a class="indexterm" name="id2714341"></a> <a class="indexterm" name="id2714354"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Get the binary log from the MySQL server on the given host. </p></li><li><p><a name="option_mysqlbinlog_local-load"></a> <a class="indexterm" name="id2714392"></a> <a class="indexterm" name="id2714405"></a> <code class="option">--local-load=<em class="replaceable"><code>path</code></em></code>, <code class="option">-l <em class="replaceable"><code>path</code></em></code> </p><p> Prepare local temporary files for <code class="literal">LOAD DATA INFILE</code> in the specified directory. </p></li><li><p><a name="option_mysqlbinlog_offset"></a> <a class="indexterm" name="id2714449"></a> <a class="indexterm" name="id2714462"></a> <code class="option">--offset=<em class="replaceable"><code>N</code></em></code>, <code class="option">-o <em class="replaceable"><code>N</code></em></code> </p><p> Skip the first <em class="replaceable"><code>N</code></em> entries in the log. </p></li><li><p><a name="option_mysqlbinlog_password"></a> <a class="indexterm" name="id2714502"></a> <a class="indexterm" name="id2714515"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlbinlog_port"></a> <a class="indexterm" name="id2714588"></a> <a class="indexterm" name="id2714600"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for connecting to a remote server. </p></li><li><p><a name="option_mysqlbinlog_position"></a> <a class="indexterm" name="id2714638"></a> <a class="indexterm" name="id2714651"></a> <code class="option">--position=<em class="replaceable"><code>N</code></em></code>, <code class="option">-j <em class="replaceable"><code>N</code></em></code> </p><p> Deprecated. Use <code class="option">--start-position</code> instead. </p></li><li><p><a name="option_mysqlbinlog_protocol"></a> <a class="indexterm" name="id2714692"></a> <a class="indexterm" name="id2714704"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqlbinlog_read-from-remote-server"></a> <a class="indexterm" name="id2714734"></a> <a class="indexterm" name="id2714747"></a> <code class="option">--read-from-remote-server</code>, <code class="option">-R</code> </p><p> Read the binary log from a MySQL server rather than reading a local log file. Any connection parameter options are ignored unless this option is given as well. These options are <code class="option">--host</code>, <code class="option">--password</code>, <code class="option">--port</code>, <code class="option">--protocol</code>, <code class="option">--socket</code>, and <code class="option">--user</code>. </p></li><li><p><a name="option_mysqlbinlog_result-file"></a> <a class="indexterm" name="id2714806"></a> <a class="indexterm" name="id2714818"></a> <code class="option">--result-file=<em class="replaceable"><code>name</code></em></code>, <code class="option">-r <em class="replaceable"><code>name</code></em></code> </p><p> Direct output to the given file. </p></li><li><p><a name="option_mysqlbinlog_set-charset"></a> <a class="indexterm" name="id2714856"></a> <a class="indexterm" name="id2714869"></a> <code class="option">--set-charset=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Add a <code class="literal">SET NAMES <em class="replaceable"><code>charset_name</code></em></code> statement to the output to specify the character set to be used for processing log files. This option was added in MySQL 5.0.23. </p></li><li><p><a name="option_mysqlbinlog_short-form"></a> <a class="indexterm" name="id2714912"></a> <a class="indexterm" name="id2714924"></a> <code class="option">--short-form</code>, <code class="option">-s</code> </p><p> Display only the statements contained in the log, without any extra information. </p></li><li><p><a name="option_mysqlbinlog_socket"></a> <a class="indexterm" name="id2714958"></a> <a class="indexterm" name="id2714971"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqlbinlog_start-datetime"></a> <a class="indexterm" name="id2715016"></a> <a class="indexterm" name="id2715028"></a> <code class="option">--start-datetime=<em class="replaceable"><code>datetime</code></em></code> </p><p> Start reading the binary log at the first event having a timestamp equal to or later than the <em class="replaceable"><code>datetime</code></em> argument. The <em class="replaceable"><code>datetime</code></em> value is relative to the local time zone on the machine where you run <span><strong class="command">mysqlbinlog</strong></span>. The value should be in a format accepted for the <code class="literal">DATETIME</code> or <code class="literal">TIMESTAMP</code> data types. For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000003</code></strong> </pre><p> This option is useful for point-in-time recovery. See <a href="server-administration.html#backup-strategy-example" title="5.9.2. Example Backup and Recovery Strategy">Section 5.9.2, “Example Backup and Recovery Strategy”</a>. </p></li><li><p><a name="option_mysqlbinlog_stop-datetime"></a> <a class="indexterm" name="id2715113"></a> <a class="indexterm" name="id2715126"></a> <code class="option">--stop-datetime=<em class="replaceable"><code>datetime</code></em></code> </p><p> Stop reading the binary log at the first event having a timestamp equal or posterior to the <em class="replaceable"><code>datetime</code></em> argument. This option is useful for point-in-time recovery. See the description of the <code class="option">--start-datetime</code> option for information about the <em class="replaceable"><code>datetime</code></em> value. </p></li><li><p><a name="option_mysqlbinlog_start-position"></a> <a class="indexterm" name="id2715173"></a> <a class="indexterm" name="id2715186"></a> <code class="option">--start-position=<em class="replaceable"><code>N</code></em></code> </p><p> Start reading the binary log at the first event having a position equal to the <em class="replaceable"><code>N</code></em> argument. This option applies to the first log file named on the command line. </p></li><li><p><a name="option_mysqlbinlog_stop-position"></a> <a class="indexterm" name="id2715224"></a> <a class="indexterm" name="id2715237"></a> <code class="option">--stop-position=<em class="replaceable"><code>N</code></em></code> </p><p> Stop reading the binary log at the first event having a position equal or greater than the <em class="replaceable"><code>N</code></em> argument. This option applies to the last log file named on the command line. </p></li><li><p><a name="option_mysqlbinlog_to-last-log"></a> <a class="indexterm" name="id2715275"></a> <a class="indexterm" name="id2715287"></a> <code class="option">--to-last-log</code>, <code class="option">-t</code> </p><p> Do not stop at the end of the requested binary log from a MySQL server, but rather continue printing until the end of the last binary log. If you send the output to the same MySQL server, this may lead to an endless loop. This option requires <code class="option">--read-from-remote-server</code>. </p></li><li><p><a name="option_mysqlbinlog_user"></a> <a class="indexterm" name="id2715329"></a> <a class="indexterm" name="id2715341"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to a remote server. </p></li><li><p><a name="option_mysqlbinlog_version"></a> <a class="indexterm" name="id2715379"></a> <a class="indexterm" name="id2715392"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div><p> You can also set the following variable by using <code class="option">--<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlbinlog_open_files_limit"></a> <a class="indexterm" name="id2715442"></a> <code class="literal">open_files_limit</code> </p><p> Specify the number of open file descriptors to reserve. </p></li></ul></div><p> It is also possible to set variables by using <code class="option">--set-variable=<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> or <code class="option">-O <em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax. <span class="emphasis"><em>This syntax is deprecated</em></span>. </p><p> You can pipe the output of <span><strong class="command">mysqlbinlog</strong></span> into the <span><strong class="command">mysql</strong></span> client to execute the statements contained in the binary log. This is used to recover from a crash when you have an old backup (see <a href="server-administration.html#backup" title="5.9.1. Database Backups">Section 5.9.1, “Database Backups”</a>). For example: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.000001 | mysql</code></strong> </pre><p> Or: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.[0-9]* | mysql</code></strong> </pre><p> You can also redirect the output of <span><strong class="command">mysqlbinlog</strong></span> to a text file instead, if you need to modify the statement log first (for example, to remove statements that you do not want to execute for some reason). After editing the file, execute the statements that it contains by using it as input to the <span><strong class="command">mysql</strong></span> program. </p><p> <span><strong class="command">mysqlbinlog</strong></span> has the <code class="option">--start-position</code> option, which prints only those statements with an offset in the binary log greater than or equal to a given position (the given position must match the start of one event). It also has options to stop and start when it sees an event with a given date and time. This enables you to perform point-in-time recovery using the <code class="option">--stop-datetime</code> option (to be able to say, for example, “<span class="quote">roll forward my databases to how they were today at 10:30 a.m.</span>”). </p><p> If you have more than one binary log to execute on the MySQL server, the safe method is to process them all using a single connection to the server. Here is an example that demonstrates what may be <span class="emphasis"><em>unsafe</em></span>: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.000001 | mysql # DANGER!!</code></strong> shell> <strong class="userinput"><code>mysqlbinlog binlog.000002 | mysql # DANGER!!</code></strong> </pre><p> Processing binary logs this way using different connections to the server causes problems if the first log file contains a <code class="literal">CREATE TEMPORARY TABLE</code> statement and the second log contains a statement that uses the temporary table. When the first <span><strong class="command">mysql</strong></span> process terminates, the server drops the temporary table. When the second <span><strong class="command">mysql</strong></span> process attempts to use the table, the server reports “<span class="quote">unknown table.</span>” </p><p> To avoid problems like this, use a <span class="emphasis"><em>single</em></span> connection to execute the contents of all binary logs that you want to process. Here is one way to do so: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.000001 binlog.000002 | mysql</code></strong> </pre><p> Another approach is to write all the logs to a single file and then process the file: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog binlog.000001 > /tmp/statements.sql</code></strong> shell> <strong class="userinput"><code>mysqlbinlog binlog.000002 >> /tmp/statements.sql</code></strong> shell> <strong class="userinput"><code>mysql -e "source /tmp/statements.sql"</code></strong> </pre><p> <span><strong class="command">mysqlbinlog</strong></span> can produce output that reproduces a <code class="literal">LOAD DATA INFILE</code> operation without the original data file. <span><strong class="command">mysqlbinlog</strong></span> copies the data to a temporary file and writes a <code class="literal">LOAD DATA LOCAL INFILE</code> statement that refers to the file. The default location of the directory where these files are written is system-specific. To specify a directory explicitly, use the <code class="option">--local-load</code> option. </p><p> Because <span><strong class="command">mysqlbinlog</strong></span> converts <code class="literal">LOAD DATA INFILE</code> statements to <code class="literal">LOAD DATA LOCAL INFILE</code> statements (that is, it adds <code class="literal">LOCAL</code>), both the client and the server that you use to process the statements must be configured to allow <code class="literal">LOCAL</code> capability. See <a href="server-administration.html#load-data-local" title="5.6.4. Security Issues with LOAD DATA LOCAL">Section 5.6.4, “Security Issues with <code class="literal">LOAD DATA LOCAL</code>”</a>. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on the security implications of enabling <code class="literal">LOCAL</code>, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p> The temporary files created for <code class="literal">LOAD DATA LOCAL</code> statements are <span class="emphasis"><em>not</em></span> automatically deleted because they are needed until you actually execute those statements. You should delete the temporary files yourself after you no longer need the statement log. The files can be found in the temporary file directory and have names like <em class="replaceable"><code>original_file_name-#-#</code></em>. </p></div><p> The <code class="option">--hexdump</code> option produces a hex dump of the log contents in comments: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlbinlog --hexdump master-bin.000001</code></strong> </pre><p> With the preceding command, the output might look like this: </p><pre class="programlisting">/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; # at 4 #051024 17:24:13 server id 1 end_log_pos 98 # Position Timestamp Type Master ID Size Master Pos Flags # 00000004 9d fc 5c 43 0f 01 00 00 00 5e 00 00 00 62 00 00 00 00 00 # 00000017 04 00 35 2e 30 2e 31 35 2d 64 65 62 75 67 2d 6c |..5.0.15.debug.l| # 00000027 6f 67 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |og..............| # 00000037 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| # 00000047 00 00 00 00 9d fc 5c 43 13 38 0d 00 08 00 12 00 |.......C.8......| # 00000057 04 04 04 04 12 00 00 4b 00 04 1a |.......K...| # Start: binlog v 4, server v 5.0.15-debug-log created 051024 17:24:13 # at startup ROLLBACK; </pre><p> Hex dump output currently contains the following elements. This format might change in the future. </p><div class="itemizedlist"><ul type="disc"><li><p> <code class="literal">Position</code>: The byte position within the log file. </p></li><li><p> <code class="literal">Timestamp</code>: The event timestamp. In the example shown, <code class="literal">'9d fc 5c 43'</code> is the representation of <code class="literal">'051024 17:24:13'</code> in hexadecimal. </p></li><li><p> <code class="literal">Type</code>: The type of the log event. In the example shown, <code class="literal">'0f'</code> means that the example event is a <code class="literal">FORMAT_DESCRIPTION_EVENT</code>. The following table lists the possible types. </p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><tbody><tr><td>Type</td><td>Name</td><td>Meaning</td></tr><tr><td><code class="literal">00</code></td><td><code class="literal">UNKNOWN_EVENT</code></td><td>This event should never be present in the log.</td></tr><tr><td><code class="literal">01</code></td><td><code class="literal">START_EVENT_V3</code></td><td>This indicates the start of a log file written by MySQL 4 or earlier.</td></tr><tr><td><code class="literal">02</code></td><td><code class="literal">QUERY_EVENT</code></td><td>The most common type of events. These contain statements executed on the master.</td></tr><tr><td><code class="literal">03</code></td><td><code class="literal">STOP_EVENT</code></td><td>Indicates that master has stopped.</td></tr><tr><td><code class="literal">04</code></td><td><code class="literal">ROTATE_EVENT</code></td><td>Written when the master switches to a new log file.</td></tr><tr><td><code class="literal">05</code></td><td><code class="literal">INTVAR_EVENT</code></td><td>Used mainly for <code class="literal">AUTO_INCREMENT</code> values and when the <a href="functions.html#function_last-insert-id"><code class="literal">LAST_INSERT_ID()</code></a> function is used in the statement.</td></tr><tr><td><code class="literal">06</code></td><td><code class="literal">LOAD_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> in MySQL 3.23.</td></tr><tr><td><code class="literal">07</code></td><td><code class="literal">SLAVE_EVENT</code></td><td>Reserved for future use.</td></tr><tr><td><code class="literal">08</code></td><td><code class="literal">CREATE_FILE_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> statements. This indicates the start of execution of such a statement. A temporary file is created on the slave. Used in MySQL 4 only.</td></tr><tr><td><code class="literal">09</code></td><td><code class="literal">APPEND_BLOCK_EVENT</code></td><td>Contains data for use in a <code class="literal">LOAD DATA INFILE</code> statement. The data is stored in the temporary file on the slave.</td></tr><tr><td><code class="literal">0a</code></td><td><code class="literal">EXEC_LOAD_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> statements. The contents of the temporary file is stored in the table on the slave. Used in MySQL 4 only.</td></tr><tr><td><code class="literal">0b</code></td><td><code class="literal">DELETE_FILE_EVENT</code></td><td>Rollback of a <code class="literal">LOAD DATA INFILE</code> statement. The temporary file should be deleted on slave.</td></tr><tr><td><code class="literal">0c</code></td><td><code class="literal">NEW_LOAD_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> in MySQL 4 and earlier.</td></tr><tr><td><code class="literal">0d</code></td><td><code class="literal">RAND_EVENT</code></td><td>Used to send information about random values if the <a href="functions.html#function_rand"><code class="literal">RAND()</code></a> function is used in the statement.</td></tr><tr><td><code class="literal">0e</code></td><td><code class="literal">USER_VAR_EVENT</code></td><td>Used to replicate user variables.</td></tr><tr><td><code class="literal">0f</code></td><td><code class="literal">FORMAT_DESCRIPTION_EVENT</code></td><td>This indicates the start of a log file written by MySQL 5 or later.</td></tr><tr><td><code class="literal">10</code></td><td><code class="literal">XID_EVENT</code></td><td>Event indicating commit of an XA transaction.</td></tr><tr><td><code class="literal">11</code></td><td><code class="literal">BEGIN_LOAD_QUERY_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> statements in MySQL 5 and later.</td></tr><tr><td><code class="literal">12</code></td><td><code class="literal">EXECUTE_LOAD_QUERY_EVENT</code></td><td>Used for <code class="literal">LOAD DATA INFILE</code> statements in MySQL 5 and later.</td></tr><tr><td><code class="literal">13</code></td><td><code class="literal">TABLE_MAP_EVENT</code></td><td>Reserved for future use.</td></tr><tr><td><code class="literal">14</code></td><td><code class="literal">WRITE_ROWS_EVENT</code></td><td>Reserved for future use.</td></tr><tr><td><code class="literal">15</code></td><td><code class="literal">UPDATE_ROWS_EVENT</code></td><td>Reserved for future use.</td></tr><tr><td><code class="literal">16</code></td><td><code class="literal">DELETE_ROWS_EVENT</code></td><td>Reserved for future use.</td></tr></tbody></table></div></li><li><p> <code class="literal">Master ID</code>: The server id of the master that created the event. </p></li><li><p> <code class="literal">Size</code>: The size in bytes of the event. </p></li><li><p> <code class="literal">Master Pos</code>: The position of the event in the original master log file. </p></li><li><p> <code class="literal">Flags</code>: 16 flags. Currently, the following flags are used. The others are reserved for the future. </p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><tbody><tr><td>Flag</td><td>Name</td><td>Meaning</td></tr><tr><td><code class="literal">01</code></td><td><code class="literal">LOG_EVENT_BINLOG_IN_USE_F</code></td><td>Log file correctly closed. (Used only in <code class="literal">FORMAT_DESCRIPTION_EVENT</code>.) If this flag is set (if the flags are, for example, <code class="literal">'01 00'</code>) in a <code class="literal">FORMAT_DESCRIPTION_EVENT</code>, the log file has not been properly closed. Most probably this is because of a master crash (for example, due to power failure).</td></tr><tr><td><code class="literal">02</code></td><td> </td><td>Reserved for future use.</td></tr><tr><td><code class="literal">04</code></td><td><code class="literal">LOG_EVENT_THREAD_SPECIFIC_F</code></td><td>Set if the event is dependent on the connection it was executed in (for example, <code class="literal">'04 00'</code>), for example, if the event uses temporary tables.</td></tr><tr><td><code class="literal">08</code></td><td><code class="literal">LOG_EVENT_SUPPRESS_USE_F</code></td><td>Set in some circumstances when the event is not dependent on the default database.</td></tr></tbody></table></div><p> The other flags are reserved for future use. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlcheck"></a>7.11. <span><strong class="command">mysqlcheck</strong></span> — A Table Maintenance and Repair Program</h2></div></div></div><p> The <span><strong class="command">mysqlcheck</strong></span> client checks, repairs, optimizes, and analyzes tables. </p><p> <span><strong class="command">mysqlcheck</strong></span> is similar in function to <span><strong class="command">myisamchk</strong></span>, but works differently. The main operational difference is that <span><strong class="command">mysqlcheck</strong></span> must be used when the <span><strong class="command">mysqld</strong></span> server is running, whereas <span><strong class="command">myisamchk</strong></span> should be used when it is not. The benefit of using <span><strong class="command">mysqlcheck</strong></span> is that you do not have to stop the server to check or repair your tables. </p><p> <span><strong class="command">mysqlcheck</strong></span> uses the SQL statements <code class="literal">CHECK TABLE</code>, <code class="literal">REPAIR TABLE</code>, <code class="literal">ANALYZE TABLE</code>, and <code class="literal">OPTIMIZE TABLE</code> in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in <a href="sql-syntax.html" title="Chapter 12. SQL Statement Syntax">Chapter 12, <i>SQL Statement Syntax</i></a>. </p><p> The <code class="literal">MyISAM</code> storage engine supports all four statements, so <span><strong class="command">mysqlcheck</strong></span> can be used to perform all four operations on <code class="literal">MyISAM</code> tables. Other storage engines do not necessarily support all operations. In such cases, an error message is displayed. For example, if <code class="literal">test.t</code> is a <code class="literal">MEMORY</code> table, an attempt to check it produces this result: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlcheck test t</code></strong> test.t note : The storage engine for the table doesn't support check </pre><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p> It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to filesystem errors. </p></div><p> There are three general ways to invoke <span><strong class="command">mysqlcheck</strong></span>: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlcheck [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>db_name</code></em> [<em class="replaceable"><code>tables</code></em>]</code></strong> shell> <strong class="userinput"><code>mysqlcheck [<em class="replaceable"><code>options</code></em>] --databases <em class="replaceable"><code>db_name1</code></em> [<em class="replaceable"><code>db_name2</code></em> <em class="replaceable"><code>db_name3</code></em>...]</code></strong> shell> <strong class="userinput"><code>mysqlcheck [<em class="replaceable"><code>options</code></em>] --all-databases</code></strong> </pre><p> If you do not name any tables following <em class="replaceable"><code>db_name</code></em> or if you use the <code class="option">--databases</code> or <code class="option">--all-databases</code> option, entire databases are checked. </p><p> <span><strong class="command">mysqlcheck</strong></span> has a special feature compared to other client programs. The default behavior of checking tables (<code class="option">--check</code>) can be changed by renaming the binary. If you want to have a tool that repairs tables by default, you should just make a copy of <span><strong class="command">mysqlcheck</strong></span> named <span><strong class="command">mysqlrepair</strong></span>, or make a symbolic link to <span><strong class="command">mysqlcheck</strong></span> named <span><strong class="command">mysqlrepair</strong></span>. If you invoke <span><strong class="command">mysqlrepair</strong></span>, it repairs tables. </p><p> The following names can be used to change <span><strong class="command">mysqlcheck</strong></span> default behavior: </p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><span><strong class="command">mysqlrepair</strong></span></td><td>The default option is <code class="option">--repair</code></td></tr><tr><td><span><strong class="command">mysqlanalyze</strong></span></td><td>The default option is <code class="option">--analyze</code></td></tr><tr><td><span><strong class="command">mysqloptimize</strong></span></td><td>The default option is <code class="option">--optimize</code></td></tr></tbody></table></div><p> <span><strong class="command">mysqlcheck</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlcheck_help"></a> <a class="indexterm" name="id2717170"></a> <a class="indexterm" name="id2717183"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlcheck_all-databases"></a> <a class="indexterm" name="id2717215"></a> <a class="indexterm" name="id2717228"></a> <code class="option">--all-databases</code>, <code class="option">-A</code> </p><p> Check all tables in all databases. This is the same as using the <code class="option">--databases</code> option and naming all the databases on the command line. </p></li><li><p><a name="option_mysqlcheck_all-in-1"></a> <a class="indexterm" name="id2717266"></a> <a class="indexterm" name="id2717279"></a> <code class="option">--all-in-1</code>, <code class="option">-1</code> </p><p> Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed. </p></li><li><p><a name="option_mysqlcheck_analyze"></a> <a class="indexterm" name="id2717314"></a> <a class="indexterm" name="id2717326"></a> <code class="option">--analyze</code>, <code class="option">-a</code> </p><p> Analyze the tables. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on optimizing tables, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_mysqlcheck_auto-repair"></a> <a class="indexterm" name="id2717379"></a> <a class="indexterm" name="id2717392"></a> <code class="option">--auto-repair</code> </p><p> If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked. </p></li><li><p><a name="option_mysqlcheck_character-sets-dir"></a> <a class="indexterm" name="id2717424"></a> <a class="indexterm" name="id2717436"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlcheck_check"></a> <a class="indexterm" name="id2717474"></a> <a class="indexterm" name="id2717486"></a> <code class="option">--check</code>, <code class="option">-c</code> </p><p> Check the tables for errors. This is the default operation. </p></li><li><p><a name="option_mysqlcheck_check-only-changed"></a> <a class="indexterm" name="id2717520"></a> <a class="indexterm" name="id2717532"></a> <code class="option">--check-only-changed</code>, <code class="option">-C</code> </p><p> Check only tables that have changed since the last check or that have not been closed properly. </p></li><li><p><a name="coption_mysqlcheck_check-upgrade"></a> <a class="indexterm" name="id2717567"></a> <a class="indexterm" name="id2717579"></a> <code class="option">--check-upgrade</code>, <code class="option">-g</code> </p><p> Invoke <code class="literal">CHECK TABLE</code> with the <code class="literal">FOR UPGRADE</code> option to check tables for incompatibilities with the current version of the server. This option was added in MySQL 5.0.19. </p></li><li><p><a name="option_mysqlcheck_compress"></a> <a class="indexterm" name="id2717626"></a> <a class="indexterm" name="id2717639"></a> <code class="option">--compress</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysqlcheck_databases"></a> <a class="indexterm" name="id2717669"></a> <a class="indexterm" name="id2717682"></a> <code class="option">--databases</code>, <code class="option">-B</code> </p><p> Process all tables in the named databases. Normally, <span><strong class="command">mysqlcheck</strong></span> 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. </p></li><li><p><a name="option_mysqlcheck_debug"></a> <a class="indexterm" name="id2717724"></a> <a class="indexterm" name="id2717737"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. A typical <em class="replaceable"><code>debug_options</code></em> string is often <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_mysqlcheck_default-character-set"></a> <a class="indexterm" name="id2717792"></a> <a class="indexterm" name="id2717804"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlcheck_extended"></a> <a class="indexterm" name="id2717846"></a> <a class="indexterm" name="id2717858"></a> <code class="option">--extended</code>, <code class="option">-e</code> </p><p> If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time. </p><p> If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also! </p></li><li><p><a name="option_mysqlcheck_fast"></a> <a class="indexterm" name="id2717899"></a> <a class="indexterm" name="id2717912"></a> <code class="option">--fast</code>, <code class="option">-F</code> </p><p> Check only tables that have not been closed properly. </p></li><li><p><a name="option_mysqlcheck_force"></a> <a class="indexterm" name="id2717944"></a> <a class="indexterm" name="id2717957"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Continue even if an SQL error occurs. </p></li><li><p><a name="option_mysqlcheck_host"></a> <a class="indexterm" name="id2717990"></a> <a class="indexterm" name="id2718002"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysqlcheck_medium-check"></a> <a class="indexterm" name="id2718040"></a> <a class="indexterm" name="id2718052"></a> <code class="option">--medium-check</code>, <code class="option">-m</code> </p><p> Do a check that is faster than an <code class="option">--extended</code> operation. This finds only 99.99% of all errors, which should be good enough in most cases. </p></li><li><p><a name="option_mysqlcheck_optimized"></a> <a class="indexterm" name="id2718091"></a> <a class="indexterm" name="id2718103"></a> <code class="option">--optimize</code>, <code class="option">-o</code> </p><p> Optimize the tables. </p></li><li><p><a name="option_mysqlcheck_password"></a> <a class="indexterm" name="id2718136"></a> <a class="indexterm" name="id2718148"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlcheck_port"></a> <a class="indexterm" name="id2718221"></a> <a class="indexterm" name="id2718233"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysqlcheck_protocol"></a> <a class="indexterm" name="id2718271"></a> <a class="indexterm" name="id2718284"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqlcheck_quick"></a> <a class="indexterm" name="id2718313"></a> <a class="indexterm" name="id2718326"></a> <code class="option">--quick</code>, <code class="option">-q</code> </p><p> If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method. </p><p> If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method. </p></li><li><p><a name="option_mysqlcheck_repair"></a> <a class="indexterm" name="id2718367"></a> <a class="indexterm" name="id2718379"></a> <code class="option">--repair</code>, <code class="option">-r</code> </p><p> Perform a repair that can fix almost anything except unique keys that are not unique. </p></li><li><p><a name="option_mysqlcheck_silent"></a> <a class="indexterm" name="id2718413"></a> <a class="indexterm" name="id2718426"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Print only error messages. </p></li><li><p><a name="option_mysqlcheck_socket"></a> <a class="indexterm" name="id2718458"></a> <a class="indexterm" name="id2718471"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqlcheck_ssl"></a> <a class="indexterm" name="id2718516"></a> <a class="indexterm" name="id2718528"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysqlcheck_tables"></a> <a class="indexterm" name="id2718568"></a> <a class="indexterm" name="id2718580"></a> <code class="option">--tables</code> </p><p> Overrides the <code class="option">--databases</code> or <code class="option">-B</code> option. All name arguments following the option are regarded as table names. </p></li><li><p><a name="option_mysqlcheck_use-frm"></a> <a class="indexterm" name="id2718618"></a> <a class="indexterm" name="id2718631"></a> <code class="option">--use-frm</code> </p><p> For repair operations on <code class="literal">MyISAM</code> tables, get the table structure from the <code class="filename">.frm</code> file so that the table can be repaired even if the <code class="filename">.MYI</code> header is corrupted. </p></li><li><p><a name="option_mysqlcheck_user"></a> <a class="indexterm" name="id2718680"></a> <a class="indexterm" name="id2718692"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysqlcheck_verbose"></a> <a class="indexterm" name="id2718730"></a> <a class="indexterm" name="id2718743"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print information about the various stages of program operation. </p></li><li><p><a name="option_mysqlcheck_version"></a> <a class="indexterm" name="id2718776"></a> <a class="indexterm" name="id2718789"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqldump"></a>7.12. <span><strong class="command">mysqldump</strong></span> — A Database Backup Program</h2></div></div></div><p> The <span><strong class="command">mysqldump</strong></span> 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 transfer to another SQL server (not necessarily a MySQL server). The dump typically contains SQL statements to create the table, populate it, or both. However, <span><strong class="command">mysqldump</strong></span> can also be used to generate files in CSV, other delimited text, or XML format. </p><p> If you are doing a backup on the server and your tables all are <code class="literal">MyISAM</code> tables, consider using the <span><strong class="command">mysqlhotcopy</strong></span> instead because it can accomplish faster backups and faster restores. See <a href="client-utility-programs.html#mysqlhotcopy" title="7.13. mysqlhotcopy — A Database Backup Program">Section 7.13, “<span><strong class="command">mysqlhotcopy</strong></span> — A Database Backup Program”</a>. </p><p> There are three general ways to invoke <span><strong class="command">mysqldump</strong></span>: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>db_name</code></em> [<em class="replaceable"><code>tables</code></em>]</code></strong> shell> <strong class="userinput"><code>mysqldump [<em class="replaceable"><code>options</code></em>] --databases <em class="replaceable"><code>db_name1</code></em> [<em class="replaceable"><code>db_name2</code></em> <em class="replaceable"><code>db_name3</code></em>...]</code></strong> shell> <strong class="userinput"><code>mysqldump [<em class="replaceable"><code>options</code></em>] --all-databases</code></strong> </pre><p> If you do not name any tables following <em class="replaceable"><code>db_name</code></em> or if you use the <code class="option">--databases</code> or <code class="option">--all-databases</code> option, entire databases are dumped. </p><p> To get a list of the options your version of <span><strong class="command">mysqldump</strong></span> supports, execute <span><strong class="command">mysqldump --help</strong></span>. </p><p> Some <span><strong class="command">mysqldump</strong></span> options are shorthand for groups of other options. <code class="option">--opt</code> and <code class="option">--compact</code> fall into this category. For example, use of <code class="option">--opt</code> is the same as specifying <code class="option">--add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset</code>. Note that all of the options that <code class="option">--opt</code> stands for also are on by default because <code class="option">--opt</code> is on by default. </p><p> To reverse the effect of a group option, uses its <code class="option">--skip-<em class="replaceable"><code>xxx</code></em></code> form (<code class="option">--skip-opt</code> or <code class="option">--skip-compact</code>). It is also possible to select only part of the effect of a group option by following it with options that enable or disable specific features. Here are some examples: </p><div class="itemizedlist"><ul type="disc"><li><p> To select the effect of <code class="option">--opt</code> except for some features, use the <code class="option">--skip</code> option for each feature. For example, to disable extended inserts and memory buffering, use <code class="option">--opt --skip-extended-insert --skip-quick</code>. (As of MySQL 5.0, <code class="option">--skip-extended-insert --skip-quick</code> is sufficient because <code class="option">--opt</code> is on by default.) </p></li><li><p> To reverse <code class="option">--opt</code> for all features except index disabling and table locking, use <code class="option">--skip-opt --disable-keys --lock-tables</code>. </p></li></ul></div><p> When you selectively enable or disable the effect of a group option, order is important because options are processed first to last. For example, <code class="option">--disable-keys --lock-tables --skip-opt</code> would not have the intended effect; it is the same as <code class="option">--skip-opt</code> by itself. </p><p> <span><strong class="command">mysqldump</strong></span> can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you are dumping large tables. To dump tables row by row, use the <code class="option">--quick</code> option (or <code class="option">--opt</code>, which enables <code class="option">--quick</code>). <code class="option">--opt</code> (and hence <code class="option">--quick</code>) is enabled by default as of MySQL 5.0 to enable memory buffering, use <code class="option">--skip-quick</code>. </p><p> If you are using a recent version of <span><strong class="command">mysqldump</strong></span> to generate a dump to be reloaded into a very old MySQL server, you should not use the <code class="option">--opt</code> or <code class="option">--extended-insert</code> option. Use <code class="option">--skip-opt</code> instead. </p><p> Before MySQL 4.1.2, out-of-range numeric values such as <code class="literal">-inf</code> and <code class="literal">inf</code>, as well as <code class="literal">NaN</code> (not-a-number) values are dumped by <span><strong class="command">mysqldump</strong></span> as <code class="literal">NULL</code>. You can see this using the following sample table: </p><pre class="programlisting">mysql> <strong class="userinput"><code>CREATE TABLE t (f DOUBLE);</code></strong> mysql> <strong class="userinput"><code>INSERT INTO t VALUES(1e+111111111111111111111);</code></strong> mysql> <strong class="userinput"><code>INSERT INTO t VALUES(-1e111111111111111111111);</code></strong> mysql> <strong class="userinput"><code>SELECT f FROM t;</code></strong> +------+ | f | +------+ | inf | | -inf | +------+ </pre><p> For this table, <span><strong class="command">mysqldump</strong></span> produces the following data output: </p><pre class="programlisting">-- -- Dumping data for table `t` -- INSERT INTO t VALUES (NULL); INSERT INTO t VALUES (NULL); </pre><p> The significance of this behavior is that if you dump and restore the table, the new table has contents that differ from the original contents. This problem is fixed as of MySQL 4.1.2; you cannot insert <code class="literal">inf</code> in the table, so this <span><strong class="command">mysqldump</strong></span> behavior is only relevant when you deal with old servers. </p><p> <span><strong class="command">mysqldump</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqldump_help"></a> <a class="indexterm" name="id2719289"></a> <a class="indexterm" name="id2719301"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqldump_add-drop-database"></a> <a class="indexterm" name="id2719334"></a> <a class="indexterm" name="id2719346"></a> <code class="option">--add-drop-database</code> </p><p> Add a <code class="literal">DROP DATABASE</code> statement before each <code class="literal">CREATE DATABASE</code> statement. </p></li><li><p><a name="option_mysqldump_add-drop-table"></a> <a class="indexterm" name="id2719388"></a> <a class="indexterm" name="id2719401"></a> <code class="option">--add-drop-table</code> </p><p> Add a <code class="literal">DROP TABLE</code> statement before each <code class="literal">CREATE TABLE</code> statement. </p></li><li><p><a name="option_mysqldump_add-locks"></a> <a class="indexterm" name="id2719443"></a> <a class="indexterm" name="id2719456"></a> <code class="option">--add-locks</code> </p><p> Surround each table dump with <code class="literal">LOCK TABLES</code> and <code class="literal">UNLOCK TABLES</code> statements. This results in faster inserts when the dump file is reloaded. See <a href="optimization.html#insert-speed" title="6.2.17. Speed of INSERT Statements">Section 6.2.17, “Speed of <code class="literal">INSERT</code> Statements”</a>. </p></li><li><p><a name="option_mysqldump_all-databases"></a> <a class="indexterm" name="id2719504"></a> <a class="indexterm" name="id2719516"></a> <code class="option">--all-databases</code>, <code class="option">-A</code> </p><p> Dump all tables in all databases. This is the same as using the <code class="option">--databases</code> option and naming all the databases on the command line. </p></li><li><p><a name="option_mysqldump_allow-keywords"></a> <a class="indexterm" name="id2719555"></a> <a class="indexterm" name="id2719568"></a> <code class="option">--allow-keywords</code> </p><p> Allow creation of column names that are keywords. This works by prefixing each column name with the table name. </p></li><li><p><a name="option_mysqldump_character-sets-dir"></a> <a class="indexterm" name="id2719599"></a> <a class="indexterm" name="id2719612"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqldump_comments"></a> <a class="indexterm" name="id2719649"></a> <a class="indexterm" name="id2719662"></a> <code class="option">--comments</code>, <code class="option">-i</code> </p><p> Write additional information in the dump file such as program version, server version, and host. This option is enabled by default. To suppress this additional information, use <code class="option">--skip-comments</code>. </p></li><li><p><a name="option_mysqldump_compact"></a> <a class="indexterm" name="id2719701"></a> <a class="indexterm" name="id2719713"></a> <code class="option">--compact</code> </p><p> Produce less verbose output. This option enables the <code class="option">--skip-add-drop-table</code>, <code class="option">--skip-add-locks</code>, <code class="option">--skip-comments</code>, <code class="option">--skip-disable-keys</code>, and <code class="option">--skip-set-charset</code> options. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> Prior to release 5.0.48, this option did not create valid SQL if the database dump contained views. The recreation of views requires the creation and removal of temporary tables and this option suppressed the removal of those temporary tables. As a workaround, use <code class="option">--compress</code> with the <code class="option">--add-drop-table</code> option and then manually adjust the dump file. </p></div></li><li><p><a name="option_mysqldump_compatible"></a> <a class="indexterm" name="id2719785"></a> <a class="indexterm" name="id2719798"></a> <code class="option">--compatible=<em class="replaceable"><code>name</code></em></code> </p><p> Produce output that is more compatible with other database systems or with older MySQL servers. The value of <code class="literal">name</code> can be <code class="literal">ansi</code>, <code class="literal">mysql323</code>, <code class="literal">mysql40</code>, <code class="literal">postgresql</code>, <code class="literal">oracle</code>, <code class="literal">mssql</code>, <code class="literal">db2</code>, <code class="literal">maxdb</code>, <code class="literal">no_key_options</code>, <code class="literal">no_table_options</code>, or <code class="literal">no_field_options</code>. 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 <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>. </p><p> 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, <code class="option">--compatible=oracle</code> does not map data types to Oracle types or use Oracle comment syntax. </p><p> <span class="emphasis"><em>This option requires a server version of 4.1.0 or higher</em></span>. With older servers, it does nothing. </p></li><li><p><a name="option_mysqldump_complete-insert-option"></a> <a class="indexterm" name="id2719933"></a> <a class="indexterm" name="id2719946"></a> <code class="option">--complete-insert</code>, <code class="option">-c</code> </p><p> Use complete <code class="literal">INSERT</code> statements that include column names. </p></li><li><p><a name="option_mysqldump_compress"></a> <a class="indexterm" name="id2719985"></a> <a class="indexterm" name="id2719997"></a> <code class="option">--compress</code>, <code class="option">-C</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysqldump_create-options"></a> <a class="indexterm" name="id2720031"></a> <a class="indexterm" name="id2720044"></a> <code class="option">--create-options</code> </p><p> Include all MySQL-specific table options in the <code class="literal">CREATE TABLE</code> statements. </p></li><li><p><a name="option_mysqldump_databases"></a> <a class="indexterm" name="id2720080"></a> <a class="indexterm" name="id2720093"></a> <code class="option">--databases</code>, <code class="option">-B</code> </p><p> Dump several databases. Normally, <span><strong class="command">mysqldump</strong></span> 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. <code class="literal">CREATE DATABASE</code> and <code class="literal">USE</code> statements are included in the output before each new database. </p></li><li><p><a name="option_mysqldump_debug"></a> <a class="indexterm" name="id2720148"></a> <a class="indexterm" name="id2720161"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string is often <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. The default value is <code class="literal">'d:t:o,/tmp/mysqldump.trace'</code>. </p></li><li><p><a name="option_mysqldump_default-character-set"></a> <a class="indexterm" name="id2720222"></a> <a class="indexterm" name="id2720235"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. If no character set is specified, <span><strong class="command">mysqldump</strong></span> uses <code class="literal">utf8</code>, and earlier versions use <code class="literal">latin1</code>. </p></li><li><p><a name="option_mysqldump_delayed-insert"></a> <a class="indexterm" name="id2720296"></a> <a class="indexterm" name="id2720309"></a> <code class="option">--delayed-insert</code> </p><p> Write <code class="literal">INSERT DELAYED</code> statements rather than <code class="literal">INSERT</code> statements. </p></li><li><p><a name="option_mysqldump_delete-master-logs"></a> <a class="indexterm" name="id2720351"></a> <a class="indexterm" name="id2720364"></a> <code class="option">--delete-master-logs</code> </p><p> On a master replication server, delete the binary logs after performing the dump operation. This option automatically enables <code class="option">--master-data</code>. </p></li><li><p><a name="option_mysqldump_disable-keys"></a> <a class="indexterm" name="id2720399"></a> <a class="indexterm" name="id2720412"></a> <code class="option">--disable-keys</code>, <code class="option">-K</code> </p><p> For each table, surround the <code class="literal">INSERT</code> statements with <code class="literal">/*!40000 ALTER TABLE <em class="replaceable"><code>tbl_name</code></em> DISABLE KEYS */;</code> and <code class="literal">/*!40000 ALTER TABLE <em class="replaceable"><code>tbl_name</code></em> ENABLE KEYS */;</code> statements. This makes loading the dump file faster because the indexes are created after all rows are inserted. This option is effective only for non-unique indexes of <code class="literal">MyISAM</code> tables. </p></li><li><p><a name="option_mysqldump_dump-date"></a> <a class="indexterm" name="id2720481"></a> <a class="indexterm" name="id2720494"></a> <code class="option">--dump-date</code> </p><p> <span><strong class="command">mysqldump</strong></span> produces a <code class="literal">-- Dump completed on <em class="replaceable"><code>DATE</code></em></code> comment at the end of the dump if the <code class="option">--comments</code> option is given. However, the date causes dump files for identical data take at different times to appear to be different. <code class="option">--dump-date</code> and <code class="option">--skip-dump-date</code> control whether the date is added to the comment. The default is <code class="option">--dump-date</code> (include the date in the comment). <code class="option">--skip-dump-date</code> suppresses date printing. This option was added in MySQL 5.0.52. </p></li><li><p><a name="option_mysqldump_extended-insert"></a> <a class="indexterm" name="id2720563"></a> <a class="indexterm" name="id2720576"></a> <code class="option">--extended-insert</code>, <code class="option">-e</code> </p><p> Use multiple-row <code class="literal">INSERT</code> syntax that include several <code class="literal">VALUES</code> lists. This results in a smaller dump file and speeds up inserts when the file is reloaded. </p></li><li><p><a name="option_mysqldump_fields"></a> <a class="indexterm" name="id2720623"></a> <a class="indexterm" name="id2720636"></a> <code class="option">--fields-terminated-by=...</code>, <a class="indexterm" name="id2720652"></a> <a class="indexterm" name="id2720665"></a> <code class="option">--fields-enclosed-by=...</code>, <a class="indexterm" name="id2720682"></a> <a class="indexterm" name="id2720695"></a> <code class="option">--fields-optionally-enclosed-by=...</code>, <a class="indexterm" name="id2720712"></a> <a class="indexterm" name="id2720725"></a> <code class="option">--fields-escaped-by=...</code> </p><p> These options are used with the <code class="option">-T</code> option and have the same meaning as the corresponding clauses for <code class="literal">LOAD DATA INFILE</code>. See <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>. </p></li><li><p><a name="option_mysqldump_first-slave"></a> <a class="indexterm" name="id2720770"></a> <a class="indexterm" name="id2720783"></a> <code class="option">--first-slave</code>, <code class="option">-x</code> </p><p> Deprecated. Now renamed to <code class="option">--lock-all-tables</code>. </p></li><li><p><a name="option_mysqldump_flush-logs"></a> <a class="indexterm" name="id2720820"></a> <a class="indexterm" name="id2720832"></a> <code class="option">--flush-logs</code>, <code class="option">-F</code> </p><p> Flush the MySQL server log files before starting the dump. This option requires the <code class="literal">RELOAD</code> privilege. Note that if you use this option in combination with the <code class="option">--all-databases</code> (or <code class="option">-A</code>) option, the logs are flushed <span class="emphasis"><em>for each database dumped</em></span>. The exception is when using <code class="option">--lock-all-tables</code> or <code class="option">--master-data</code>: 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 <code class="option">--flush-logs</code> together with either <code class="option">--lock-all-tables</code> or <code class="option">--master-data</code>. </p></li><li><p><a name="option_mysqldump_flush-privileges"></a> <a class="indexterm" name="id2720910"></a> <a class="indexterm" name="id2720923"></a> <code class="option">--flush-privileges</code> </p><p> Emit a <code class="literal">FLUSH PRIVILEGES</code> statement after dumping the <code class="literal">mysql</code> database. This option should be used any time the dump contains the <code class="literal">mysql</code> database and any other database that depends on the data in the <code class="literal">mysql</code> database for proper restoration. This option was added in MySQL 5.0.26. </p></li><li><p><a name="option_mysqldump_force"></a> <a class="indexterm" name="id2720981"></a> <a class="indexterm" name="id2720994"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Continue even if an SQL error occurs during a table dump. </p><p> One use for this option is to cause <span><strong class="command">mysqldump</strong></span> to continue executing even when it encounters a view that has become invalid because the defintion refers to a table that has been dropped. Without <code class="option">--force</code>, <span><strong class="command">mysqldump</strong></span> exits with an error message. With <code class="option">--force</code>, <span><strong class="command">mysqldump</strong></span> prints the error message, but it also writes a SQL comment containing the view definition to the dump output and continues executing. </p></li><li><p><a name="option_mysqldump_host"></a> <a class="indexterm" name="id2721063"></a> <a class="indexterm" name="id2721076"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Dump data from the MySQL server on the given host. The default host is <code class="literal">localhost</code>. </p></li><li><p><a name="option_mysqldump_hex-blob"></a> <a class="indexterm" name="id2721120"></a> <a class="indexterm" name="id2721132"></a> <code class="option">--hex-blob</code> </p><p> Dump binary columns using hexadecimal notation (for example, <code class="literal">'abc'</code> becomes <code class="literal">0x616263</code>). The affected data types are <code class="literal">BINARY</code>, <code class="literal">VARBINARY</code>, and <code class="literal">BLOB</code>. As of MySQL 5.0.13, <code class="literal">BIT</code> columns are affected as well. </p></li><li><p><a name="option_mysqldump_ignore-table"></a> <a class="indexterm" name="id2721200"></a> <a class="indexterm" name="id2721213"></a> <code class="option">--ignore-table=<em class="replaceable"><code>db_name.tbl_name</code></em></code> </p><p> 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. </p></li><li><p><a name="option_mysqldump_insert-ignore"></a> <a class="indexterm" name="id2721247"></a> <a class="indexterm" name="id2721260"></a> <code class="option">--insert-ignore</code> </p><p> Write <code class="literal">INSERT</code> statements with the <code class="literal">IGNORE</code> option. </p></li><li><p><a name="option_mysqldump_lines-terminated-by"></a> <a class="indexterm" name="id2721302"></a> <a class="indexterm" name="id2721314"></a> <code class="option">--lines-terminated-by=...</code> </p><p> This option is used with the <code class="option">-T</code> option and has the same meaning as the corresponding clause for <code class="literal">LOAD DATA INFILE</code>. See <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>. </p></li><li><p><a name="option_mysqldump_lock-all-tables"></a> <a class="indexterm" name="id2721360"></a> <a class="indexterm" name="id2721373"></a> <code class="option">--lock-all-tables</code>, <code class="option">-x</code> </p><p> 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 <code class="option">--single-transaction</code> and <code class="option">--lock-tables</code>. </p></li><li><p><a name="option_mysqldump_lock-tables"></a> <a class="indexterm" name="id2721416"></a> <a class="indexterm" name="id2721429"></a> <code class="option">--lock-tables</code>, <code class="option">-l</code> </p><p> Lock all tables before dumping them. The tables are locked with <code class="literal">READ LOCAL</code> to allow concurrent inserts in the case of <code class="literal">MyISAM</code> tables. For transactional tables such as <code class="literal">InnoDB</code> and <code class="literal">BDB</code>, <code class="option">--single-transaction</code> is a much better option, because it does not need to lock the tables at all. </p><p> Please note that when dumping multiple databases, <code class="option">--lock-tables</code> locks tables for each database separately. Therefore, 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. </p></li><li><p><a name="option_mysqldump_log-error"></a> <a class="indexterm" name="id2721507"></a> <a class="indexterm" name="id2721520"></a> <code class="option">--log-error=<em class="replaceable"><code>file_name</code></em></code> </p><p> Append warnings and errors to the named file. This option was added in MySQL 5.0.42. </p></li><li><p><a name="option_mysqldump_master-data"></a> <a class="indexterm" name="id2721553"></a> <a class="indexterm" name="id2721565"></a> <code class="option">--master-data[=<em class="replaceable"><code>value</code></em>]</code> </p><p> Write the binary log filename and position to the output. This option requires the <code class="literal">RELOAD</code> 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 <code class="literal">CHANGE MASTER</code> statement. If the dump is from a master server and you use it to set up a slave server, the <code class="literal">CHANGE MASTER</code> statement causes the slave to start from the correct position in the master's binary logs. If the option value is equal to 2, the <code class="literal">CHANGE MASTER</code> statement is written as an SQL comment. If the value is not specified, then the default value is 1. </p><p> The <code class="option">--master-data</code> option automatically turns off <code class="option">--lock-tables</code>. It also turns on <code class="option">--lock-all-tables</code>, unless <code class="option">--single-transaction</code> also is specified (in which case, a global read lock is acquired only for a short time at the beginning of the dump. See also the description for <code class="option">--single-transaction</code>. In all cases, any action on logs happens at the exact moment of the dump. </p></li><li><p><a name="option_mysqldump_no-autocommit"></a> <a class="indexterm" name="id2721663"></a> <a class="indexterm" name="id2721676"></a> <code class="option">--no-autocommit</code> </p><p> Enclose the <code class="literal">INSERT</code> statements for each dumped table within <code class="literal">SET AUTOCOMMIT=0</code> and <code class="literal">COMMIT</code> statements. </p></li><li><p><a name="option_mysqldump_no-create-db"></a> <a class="indexterm" name="id2721724"></a> <a class="indexterm" name="id2721737"></a> <code class="option">--no-create-db</code>, <code class="option">-n</code> </p><p> This option suppresses the <code class="literal">CREATE DATABASE</code> statements that are otherwise included in the output if the <code class="option">--databases</code> or <code class="option">--all-databases</code> option is given. </p></li><li><p><a name="option_mysqldump_no-create-info"></a> <a class="indexterm" name="id2721785"></a> <a class="indexterm" name="id2721798"></a> <code class="option">--no-create-info</code>, <code class="option">-t</code> </p><p> Do not write <code class="literal">CREATE TABLE</code> statements that re-create each dumped table. </p></li><li><p><a name="option_mysqldump_no-data"></a> <a class="indexterm" name="id2721837"></a> <a class="indexterm" name="id2721850"></a> <code class="option">--no-data</code>, <code class="option">-d</code> </p><p> Do not write any table row information (that is, do not dump table contents). This is very useful if you want to dump only the <code class="literal">CREATE TABLE</code> statement for the table. </p></li><li><p><a name="option_mysqldump_opt"></a> <a class="indexterm" name="id2721891"></a> <a class="indexterm" name="id2721903"></a> <code class="option">--opt</code> </p><p> This option is shorthand; it is the same as specifying <code class="option">--add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset</code>. It should give you a fast dump operation and produce a dump file that can be reloaded into a MySQL server quickly. </p><p> <span class="emphasis"><em>The <code class="option">--opt</code> option is enabled by default. Use <code class="option">--skip-opt</code> to disable it.</em></span> See the discussion at the beginning of this section for information about selectively enabling or disabling certain of the options affected by <code class="option">--opt</code>. </p></li><li><p><a name="option_mysqldump_order-by-primary"></a> <a class="indexterm" name="id2721964"></a> <a class="indexterm" name="id2721976"></a> <code class="option">--order-by-primary</code> </p><p> Sorts each table's rows by its primary key, or by its first unique index, if such an index exists. This is useful when dumping a <code class="literal">MyISAM</code> table to be loaded into an <code class="literal">InnoDB</code> table, but will make the dump itself take considerably longer. </p></li><li><p><a name="option_mysqldump_password"></a> <a class="indexterm" name="id2722022"></a> <a class="indexterm" name="id2722034"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqldump_port"></a> <a class="indexterm" name="id2722107"></a> <a class="indexterm" name="id2722119"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysqldump_protocol"></a> <a class="indexterm" name="id2722157"></a> <a class="indexterm" name="id2722170"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqldump_quick"></a> <a class="indexterm" name="id2722199"></a> <a class="indexterm" name="id2722212"></a> <code class="option">--quick</code>, <code class="option">-q</code> </p><p> This option is useful for dumping large tables. It forces <span><strong class="command">mysqldump</strong></span> 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. </p></li><li><p><a name="option_mysqldump_quote-names"></a> <a class="indexterm" name="id2722254"></a> <a class="indexterm" name="id2722267"></a> <code class="option">--quote-names</code>, <code class="option">-Q</code> </p><p> Quote database, table, and column names within “<span class="quote"><code class="literal">`</code></span>” characters. If the <code class="literal">ANSI_QUOTES</code> SQL mode is enabled, names are quoted within “<span class="quote"><code class="literal">"</code></span>” characters. This option is enabled by default. It can be disabled with <code class="option">--skip-quote-names</code>, but this option should be given after any option such as <code class="option">--compatible</code> that may enable <code class="option">--quote-names</code>. </p></li><li><p><a name="option_mysqldump_result-file"></a> <a class="indexterm" name="id2722336"></a> <a class="indexterm" name="id2722348"></a> <code class="option">--result-file=<em class="replaceable"><code>file</code></em></code>, <code class="option">-r <em class="replaceable"><code>file</code></em></code> </p><p> Direct output to a given file. This option should be used on Windows to prevent newline “<span class="quote"><code class="literal">\n</code></span>” characters from being converted to “<span class="quote"><code class="literal">\r\n</code></span>” carriage return/newline sequences. The result file is created and its contents overwritten, even if an error occurs while generating the dump. The previous contents are lost. </p></li><li><p><a name="option_mysqldump_routines"></a> <a class="indexterm" name="id2722406"></a> <a class="indexterm" name="id2722418"></a> <code class="option">--routines</code>, <code class="option">-R</code> </p><p> Dump stored routines (functions and procedures) from the dumped databases. Use of this option requires the <code class="literal">SELECT</code> privilege for the <code class="literal">mysql.proc</code> table. The output generated by using <code class="option">--routines</code> contains <code class="literal">CREATE PROCEDURE</code> and <code class="literal">CREATE FUNCTION</code> 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><p> If you require routines to be re-created with their original timestamp attributes, do not use <code class="option">--routines</code>. Instead, dump and reload the contents of the <code class="literal">mysql.proc</code> table directly, using a MySQL account that has appropriate privileges for the <code class="literal">mysql</code> database. </p><p> This option was added in MySQL 5.0.13. Before that, stored routines are not dumped. Routine <code class="literal">DEFINER</code> 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 <code class="literal">mysql.proc</code> table directly as described earlier. </p></li><li><p><a name="option_mysqldump_set-charset"></a> <a class="indexterm" name="id2722536"></a> <a class="indexterm" name="id2722548"></a> <code class="option">--set-charset</code> </p><p> Add <code class="literal">SET NAMES <em class="replaceable"><code>default_character_set</code></em></code> to the output. This option is enabled by default. To suppress the <code class="literal">SET NAMES</code> statement, use <code class="option">--skip-set-charset</code>. </p></li><li><p><a name="option_mysqldump_single-transaction"></a> <a class="indexterm" name="id2722598"></a> <a class="indexterm" name="id2722611"></a> <code class="option">--single-transaction</code> </p><p> This option issues a <code class="literal">BEGIN</code> SQL statement before dumping data from the server. It is useful only with transactional tables such as <code class="literal">InnoDB</code> and <code class="literal">BDB</code>, because then it dumps the consistent state of the database at the time when <code class="literal">BEGIN</code> was issued without blocking any applications. </p><p> When using this option, you should keep in mind that only <code class="literal">InnoDB</code> tables are dumped in a consistent state. For example, any <code class="literal">MyISAM</code> or <code class="literal">MEMORY</code> tables dumped while using this option may still change state. </p><p> The <code class="option">--single-transaction</code> option and the <code class="option">--lock-tables</code> option are mutually exclusive, because <code class="literal">LOCK TABLES</code> causes any pending transactions to be committed implicitly. </p><p> While a <code class="option">--single-transaction</code> dump is in process, to ensure a valid dump file (correct table contents and binary log position), no other connection should use the following statements: <code class="literal">ALTER TABLE</code>, <code class="literal">DROP TABLE</code>, <code class="literal">RENAME TABLE</code>, <code class="literal">TRUNCATE TABLE</code>. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the <code class="literal">SELECT</code> performed by <span><strong class="command">mysqldump</strong></span> to retrieve the table contents to obtain incorrect contents or fail. </p><p> This option is not supported for MySQL Cluster tables; the results cannot be guaranteed to be consistent due to the fact that the <code class="literal">NDBCluster</code> storage engine supports only the <code class="literal">READ_COMMITTED</code> transaction isolation level. You should always use <code class="literal">NDB</code> backup and restore instead. </p><p> To dump large tables, you should combine this option with <code class="option">--quick</code>. </p></li><li><p><a name="option_mysqldump_skip-comments"></a> <a class="indexterm" name="id2722801"></a> <a class="indexterm" name="id2722814"></a> <code class="option">--skip-comments</code> </p><p> See the description for the <code class="option">--comments</code> option. </p></li><li><p><a name="option_mysqldump_skip-opt"></a> <a class="indexterm" name="id2722847"></a> <a class="indexterm" name="id2722860"></a> <code class="option">--skip-opt</code> </p><p> See the description for the <code class="option">--opt</code> option. </p></li><li><p><a name="option_mysqldump_socket"></a> <a class="indexterm" name="id2722893"></a> <a class="indexterm" name="id2722905"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqldump_ssl"></a> <a class="indexterm" name="id2722950"></a> <a class="indexterm" name="id2722963"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysqldump_tab"></a> <a class="indexterm" name="id2723002"></a> <a class="indexterm" name="id2723015"></a> <code class="option">--tab=<em class="replaceable"><code>path</code></em></code>, <code class="option">-T <em class="replaceable"><code>path</code></em></code> </p><p> Produce tab-separated data files. For each dumped table, <span><strong class="command">mysqldump</strong></span> creates a <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.sql</code> file that contains the <code class="literal">CREATE TABLE</code> statement that creates the table, and a <code class="filename"><em class="replaceable"><code>tbl_name</code></em>.txt</code> file that contains its data. The option value is the directory in which to write the files. </p><p> By default, the <code class="filename">.txt</code> 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 <code class="option">--fields-<em class="replaceable"><code>xxx</code></em></code> and <code class="option">--lines-terminated-by</code> options. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> This option should be used only when <span><strong class="command">mysqldump</strong></span> is run on the same machine as the <span><strong class="command">mysqld</strong></span> server. You must have the <code class="literal">FILE</code> privilege, and the server must have permission to write files in the directory that you specify. </p></div></li><li><p><a name="option_mysqldump_tables"></a> <a class="indexterm" name="id2723138"></a> <a class="indexterm" name="id2723151"></a> <code class="option">--tables</code> </p><p> Override the <code class="option">--databases</code> or <code class="option">-B</code> option. <span><strong class="command">mysqldump</strong></span> regards all name arguments following the option as table names. </p></li><li><p> <a class="indexterm" name="id2723192"></a> <a class="indexterm" name="id2723205"></a> <code class="option">--triggers</code> </p><p> Dump triggers for each dumped table. This option is enabled by default; disable it with <code class="option">--skip-triggers</code>. This option was added in MySQL 5.0.11. Before that, triggers are not dumped. </p></li><li><p><a name="option_mysqldump_tz-utc"></a> <a class="indexterm" name="id2723241"></a> <a class="indexterm" name="id2723253"></a> <code class="option">--tz-utc</code> </p><p> Add <code class="literal">SET TIME_ZONE='+00:00'</code> to the dump file so that <code class="literal">TIMESTAMP</code> columns can be dumped and reloaded between servers in different time zones. Without this option, <code class="literal">TIMESTAMP</code> columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change. <code class="option">--tz-utc</code> also protects against changes due to daylight saving time. <code class="option">--tz-utc</code> is enabled by default. To disable it, use <code class="option">--skip-tz-utc</code>. This option was added in MySQL 5.0.15. </p></li><li><p><a name="option_mysqldump_user"></a> <a class="indexterm" name="id2723320"></a> <a class="indexterm" name="id2723332"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysqldump_verbose"></a> <a class="indexterm" name="id2723370"></a> <a class="indexterm" name="id2723383"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_mysqldump_version"></a> <a class="indexterm" name="id2723416"></a> <a class="indexterm" name="id2723428"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li><li><p><a name="option_mysqldump_where"></a> <a class="indexterm" name="id2723461"></a> <a class="indexterm" name="id2723473"></a> <code class="option">--where='<em class="replaceable"><code>where_condition</code></em>'</code>, <code class="option">-w '<em class="replaceable"><code>where_condition</code></em>'</code> </p><p> Dump only rows selected by the given <code class="literal">WHERE</code> condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter. </p><p> Examples: </p><pre class="programlisting">--where="user='jimf'" -w"userid>1" -w"userid<1" </pre></li><li><p><a name="option_mysqldump_xml"></a> <a class="indexterm" name="id2723534"></a> <a class="indexterm" name="id2723546"></a> <code class="option">--xml</code>, <code class="option">-X</code> </p><p> Write dump output as well-formed XML. </p><p> <span class="bold"><strong><code class="literal">NULL</code>, <code class="literal">'NULL'</code>, and Empty Values</strong></span>: For some column named <em class="replaceable"><code>column_name</code></em>, the <code class="literal">NULL</code> value, an empty string, and the string value <code class="literal">'NULL'</code> are distinguished from one another in the output generated by this option as follows: </p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><span class="bold"><strong>Value</strong></span>:</td><td><span class="bold"><strong>XML Representation</strong></span>:</td></tr><tr><td><code class="literal">NULL</code> (<span class="emphasis"><em>unknown value</em></span>)</td><td><code class="literal"><field name="<em class="replaceable"><code>column_name</code></em>" xsi:nil="true" /></code></td></tr><tr><td><code class="literal">''</code> (<span class="emphasis"><em>empty string</em></span>)</td><td><code class="literal"><field name="<em class="replaceable"><code>column_name</code></em>"></field></code></td></tr><tr><td><code class="literal">'NULL'</code> (<span class="emphasis"><em>string value</em></span>)</td><td><code class="literal"><field name="<em class="replaceable"><code>column_name</code></em>">NULL</field></code></td></tr></tbody></table></div><p> Beginning with MySQL 5.0.26, the output from the <span><strong class="command">mysql</strong></span> client when run using the <code class="option">--xml</code> option also follows these rules. (See <a href="client-utility-programs.html#mysql-command-options" title="7.7.1. mysql Options">Section 7.7.1, “<span><strong class="command">mysql</strong></span> Options”</a>.) </p><p> Beginning with MySQL 5.0.40, XML output from <span><strong class="command">mysqldump</strong></span> includes the XML namespace, as shown here: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --xml -u root world City</code></strong> <?xml version="1.0"?> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="world"> <table_structure name="City"> <field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" /> <field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" /> <field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" /> <field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" /> <field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" /> <key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID" Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" /> <options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079" Avg_row_length="67" Data_length="27329 3" Max_data_length="18858823439613951" Index_length="43008" Data_free="0" Auto_increment="4080" Create_time="2007-03-31 01:47:01" Updat e_time="2007-03-31 01:47:02" Collation="latin1_swedish_ci" Create_options="" Comment="" /> </table_structure> <table_data name="City"> <row> <field name="ID">1</field> <field name="Name">Kabul</field> <field name="CountryCode">AFG</field> <field name="District">Kabol</field> <field name="Population">1780000</field> </row> <em class="replaceable"><code>...</code></em> <row> <field name="ID">4079</field> <field name="Name">Rafah</field> <field name="CountryCode">PSE</field> <field name="District">Rafah</field> <field name="Population">92020</field> </row> </table_data> </database> </mysqldump> </pre><p> </p></li></ul></div><p> You can also set the following variables by using <code class="option">--<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqldump_max-allowed-packet"></a> <code class="literal">max_allowed_packet</code> </p><p> The maximum size of the buffer for client/server communication. The maximum is 1GB. </p></li><li><p><a name="option_mysqldump_net-buffer-length"></a> <code class="literal">net_buffer_length</code> </p><p> The initial size of the buffer for client/server communication. When creating multiple-row-insert statements (as with option <code class="option">--extended-insert</code> or <code class="option">--opt</code>), <span><strong class="command">mysqldump</strong></span> creates rows up to <code class="literal">net_buffer_length</code> length. If you increase this variable, you should also ensure that the <code class="literal">net_buffer_length</code> variable in the MySQL server is at least this large. </p></li></ul></div><p> It is also possible to set variables by using <code class="option">--set-variable=<em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> or <code class="option">-O <em class="replaceable"><code>var_name</code></em>=<em class="replaceable"><code>value</code></em></code> syntax. <span class="emphasis"><em>This syntax is deprecated</em></span>. </p><p> The most common use of <span><strong class="command">mysqldump</strong></span> is probably for making a backup of an entire database: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump <em class="replaceable"><code>db_name</code></em> > <em class="replaceable"><code>backup-file.sql</code></em></code></strong> </pre><p> You can read the dump file back into the server like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em> < <em class="replaceable"><code>backup-file.sql</code></em></code></strong> </pre><p> Or like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql -e "source <em class="replaceable"><code>/path-to-backup/backup-file.sql</code></em>" <em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> <span><strong class="command">mysqldump</strong></span> is also very useful for populating databases by copying data from one MySQL server to another: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --opt <em class="replaceable"><code>db_name</code></em> | mysql --host=<em class="replaceable"><code>remote_host</code></em> -C <em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> It is possible to dump several databases with one command: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --databases <em class="replaceable"><code>db_name1</code></em> [<em class="replaceable"><code>db_name2</code></em> ...] > my_databases.sql</code></strong> </pre><p> To dump all databases, use the <code class="option">--all-databases</code> option: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --all-databases > all_databases.sql</code></strong> </pre><p> For <code class="literal">InnoDB</code> tables, <code class="literal">mysqldump</code> provides a way of making an online backup: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --all-databases --single-transaction > all_databases.sql</code></strong> </pre><p> This backup just needs to acquire a global read lock on all tables (using <code class="literal">FLUSH TABLES WITH READ LOCK</code>) 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 <code class="literal">FLUSH</code> 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. </p><p> For point-in-time recovery (also known as “<span class="quote">roll-forward,</span>” 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 <a href="server-administration.html#binary-log" title="5.10.3. The Binary Log">Section 5.10.3, “The Binary Log”</a>) or at least know the binary log coordinates to which the dump corresponds: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --all-databases --master-data=2 > all_databases.sql</code></strong> </pre><p> Or: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqldump --all-databases --flush-logs --master-data=2</code></strong> <strong class="userinput"><code>> all_databases.sql</code></strong> </pre><p> The <code class="option">--master-data</code> and <code class="option">--single-transaction</code> options can be used simultaneously, which provides a convenient way to make an online backup suitable for point-in-time recovery if tables are stored using the <code class="literal">InnoDB</code> storage engine. </p><p> For more information on making backups, see <a href="server-administration.html#backup" title="5.9.1. Database Backups">Section 5.9.1, “Database Backups”</a>, and <a href="server-administration.html#backup-strategy-example" title="5.9.2. Example Backup and Recovery Strategy">Section 5.9.2, “Example Backup and Recovery Strategy”</a>. </p><a class="indexterm" name="id2724222"></a><a class="indexterm" name="id2724235"></a><a class="indexterm" name="id2724247"></a><p> If you encounter problems backing up views, please read the section that covers restrictions on views which describes a workaround for backing up views when this fails due to insufficient privileges. See <a href="restrictions.html#view-restrictions" title="F.4. Restrictions on Views">Section F.4, “Restrictions on Views”</a>. </p><p class="mnmas-kb"><b>MySQL Enterprise</b> MySQL Enterprise subscribers will find more information about <span><strong class="command">mysqldump</strong></span> in the Knowledge Base article, <a href="https://kb.mysql.com/view.php?id=5285" target="_top"> How Can I Avoid Inserting Duplicate Rows From a Dump File?</a>. Access to the MySQL Knowledge Base collection of articles is one of the advantages of subscribing to MySQL Enterprise. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlhotcopy"></a>7.13. <span><strong class="command">mysqlhotcopy</strong></span> — A Database Backup Program</h2></div></div></div><p> <span><strong class="command">mysqlhotcopy</strong></span> is a Perl script that was originally written and contributed by Tim Bunce. It uses <code class="literal">LOCK TABLES</code>, <code class="literal">FLUSH TABLES</code>, and <code class="literal">cp</code> or <code class="literal">scp</code> to make a database backup quickly. It is the fastest way to make a backup of the database or single tables, but it can be run only on the same machine where the database directories are located. <span><strong class="command">mysqlhotcopy</strong></span> works only for backing up <code class="literal">MyISAM</code> and <code class="literal">ARCHIVE</code> tables. It runs on Unix and NetWare. </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlhotcopy <em class="replaceable"><code>db_name</code></em> [<em class="replaceable"><code>/path/to/new_directory</code></em>]</code></strong> </pre><pre class="programlisting">shell> <strong class="userinput"><code>mysqlhotcopy <em class="replaceable"><code>db_name_1</code></em> ... <em class="replaceable"><code>db_name_n</code></em> <em class="replaceable"><code>/path/to/new_directory</code></em></code></strong> </pre><p> Back up tables in the given database that match a regular expression: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlhotcopy <em class="replaceable"><code>db_name</code></em>./<em class="replaceable"><code>regex</code></em>/</code></strong> </pre><p> The regular expression for the table name can be negated by prefixing it with a tilde (“<span class="quote"><code class="literal">~</code></span>”): </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlhotcopy <em class="replaceable"><code>db_name</code></em>./~<em class="replaceable"><code>regex</code></em>/</code></strong> </pre><p> <span><strong class="command">mysqlhotcopy</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlhotcopy_help"></a> <a class="indexterm" name="id2724502"></a> <a class="indexterm" name="id2724514"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlhotcopy_addtodest"></a> <a class="indexterm" name="id2724547"></a> <a class="indexterm" name="id2724559"></a> <code class="option">--addtodest</code> </p><p> Do not rename target directory (if it exists); merely add files to it. </p></li><li><p><a name="option_mysqlhotcopy_allowold"></a> <a class="indexterm" name="id2724590"></a> <a class="indexterm" name="id2724602"></a> <code class="option">--allowold</code> </p><p> Do not abort if a target exists; rename it by adding an <code class="literal">_old</code> suffix. </p></li><li><p><a name="option_mysqlhotcopy_checkpoint"></a> <a class="indexterm" name="id2724639"></a> <a class="indexterm" name="id2724651"></a> <code class="option">--checkpoint=<em class="replaceable"><code>db_name</code></em>.<em class="replaceable"><code>tbl_name</code></em></code> </p><p> Insert checkpoint entries into the specified database <em class="replaceable"><code>db_name</code></em> and table <em class="replaceable"><code>tbl_name</code></em>. </p></li><li><p><a name="option_mysqlhotcopy_chroot"></a> <a class="indexterm" name="id2724695"></a> <a class="indexterm" name="id2724708"></a> <code class="option">--chroot=<em class="replaceable"><code>path</code></em></code> </p><p> Base directory of the <span><strong class="command">chroot</strong></span> jail in which <span><strong class="command">mysqld</strong></span> operates. The <em class="replaceable"><code>path</code></em> value should match that of the <code class="option">--chroot</code> option given to <span><strong class="command">mysqld</strong></span>. </p></li><li><p><a name="option_mysqlhotcopy_debug"></a> <a class="indexterm" name="id2724767"></a> <a class="indexterm" name="id2724779"></a> <code class="option">--debug</code> </p><p> Enable debug output. </p></li><li><p><a name="option_mysqlhotcopy_dryrun"></a> <a class="indexterm" name="id2724808"></a> <a class="indexterm" name="id2724821"></a> <code class="option">--dryrun</code>, <code class="option">-n</code> </p><p> Report actions without performing them. </p></li><li><p><a name="option_mysqlhotcopy_flushlog"></a> <a class="indexterm" name="id2724854"></a> <a class="indexterm" name="id2724867"></a> <code class="option">--flushlog</code> </p><p> Flush logs after all tables are locked. </p></li><li><p><a name="option_mysqlhotcopy_host"></a> <a class="indexterm" name="id2724896"></a> <a class="indexterm" name="id2724909"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> The hostname of the local host to use for making a TCP/IP connection to the local server. By default, the connection is made to <code class="literal">localhost</code> using a Unix socket file. </p></li><li><p><a name="option_mysqlhotcopy_keepold"></a> <a class="indexterm" name="id2724955"></a> <a class="indexterm" name="id2724968"></a> <code class="option">--keepold</code> </p><p> Do not delete previous (renamed) target when done. </p></li><li><p><a name="option_mysqlhotcopy_method"></a> <a class="indexterm" name="id2724997"></a> <a class="indexterm" name="id2725010"></a> <code class="option">--method=<em class="replaceable"><code>command</code></em></code> </p><p> The method for copying files (<code class="literal">cp</code> or <code class="literal">scp</code>). </p></li><li><p><a name="option_mysqlhotcopy_noindices"></a> <a class="indexterm" name="id2725053"></a> <a class="indexterm" name="id2725066"></a> <code class="option">--noindices</code> </p><p> Do not include full index files in the backup. This makes the backup smaller and faster. The indexes for reloaded tables can be reconstructed later with <span><strong class="command">myisamchk -rq</strong></span>. </p></li><li><p><a name="option_mysqlhotcopy_password"></a> <a class="indexterm" name="id2725104"></a> <a class="indexterm" name="id2725117"></a> <code class="option">--password=<em class="replaceable"><code>password</code></em></code>, <code class="option">-p<em class="replaceable"><code>password</code></em></code> </p><p> The password to use when connecting to the server. Note that the password value is not optional for this option, unlike for other MySQL programs. You can use an option file to avoid giving the password on the command line. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlhotcopy_port"></a> <a class="indexterm" name="id2725169"></a> <a class="indexterm" name="id2725182"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use when connecting to the local server. </p></li><li><p><a name="option_mysqlhotcopy_quiet"></a> <a class="indexterm" name="id2725220"></a> <a class="indexterm" name="id2725233"></a> <code class="option">--quiet</code>, <code class="option">-q</code> </p><p> Be silent except for errors. </p></li><li><p><a name="option_mysqlhotcopy_record_log_pos"></a> <a class="indexterm" name="id2725265"></a> <a class="indexterm" name="id2725278"></a> <code class="option">--record_log_pos=<em class="replaceable"><code>db_name</code></em>.<em class="replaceable"><code>tbl_name</code></em></code> </p><p> Record master and slave status in the specified database <em class="replaceable"><code>db_name</code></em> and table <em class="replaceable"><code>tbl_name</code></em>. </p></li><li><p><a name="option_mysqlhotcopy_regexp"></a> <a class="indexterm" name="id2725322"></a> <a class="indexterm" name="id2725335"></a> <code class="option">--regexp=<em class="replaceable"><code>expr</code></em></code> </p><p> Copy all databases with names that match the given regular expression. </p></li><li><p><a name="option_mysqlhotcopy_resetmaster"></a> <a class="indexterm" name="id2725368"></a> <a class="indexterm" name="id2725380"></a> <code class="option">--resetmaster</code> </p><p> Reset the binary log after locking all the tables. </p></li><li><p><a name="option_mysqlhotcopy_resetslave"></a> <a class="indexterm" name="id2725410"></a> <a class="indexterm" name="id2725423"></a> <code class="option">--resetslave</code> </p><p> Reset the <code class="filename">master.info</code> file after locking all the tables. </p></li><li><p><a name="option_mysqlhotcopy_socket"></a> <a class="indexterm" name="id2725459"></a> <a class="indexterm" name="id2725471"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> The Unix socket file to use for the connection. </p></li><li><p><a name="option_mysqlhotcopy_suffix"></a> <a class="indexterm" name="id2725509"></a> <a class="indexterm" name="id2725522"></a> <code class="option">--suffix=<em class="replaceable"><code>str</code></em></code> </p><p> The suffix for names of copied databases. </p></li><li><p><a name="option_mysqlhotcopy_tmpdir"></a> <a class="indexterm" name="id2725554"></a> <a class="indexterm" name="id2725566"></a> <code class="option">--tmpdir=<em class="replaceable"><code>path</code></em></code> </p><p> The temporary directory. The default is <code class="filename">/tmp</code>. </p></li><li><p><a name="option_mysqlhotcopy_user"></a> <a class="indexterm" name="id2725605"></a> <a class="indexterm" name="id2725617"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li></ul></div><p> <span><strong class="command">mysqlhotcopy</strong></span> reads the <code class="literal">[client]</code> and <code class="literal">[mysqlhotcopy]</code> option groups from option files. </p><p> To execute <span><strong class="command">mysqlhotcopy</strong></span>, you must have access to the files for the tables that you are backing up, the <code class="literal">SELECT</code> privilege for those tables, the <code class="literal">RELOAD</code> privilege (to be able to execute <code class="literal">FLUSH TABLES</code>), and the <code class="literal">LOCK TABLES</code> privilege (to be able to lock the tables). </p><p> Use <code class="literal">perldoc</code> for additional <span><strong class="command">mysqlhotcopy</strong></span> documentation, including information about the structure of the tables needed for the <code class="option">--checkpoint</code> and <code class="option">--record_log_pos</code> options: </p><pre class="programlisting">shell> <strong class="userinput"><code>perldoc mysqlhotcopy</code></strong> </pre><p class="mnmas-kb"><b>MySQL Enterprise</b> MySQL Enterprise subscribers will find more information about <span><strong class="command">mysqlhotcopy</strong></span> in the Knowledge Base article, <a href="https://kb.mysql.com/view.php?id=5919" target="_top"> How Does mysqlhotcopy Work?</a>. Access to the MySQL Knowledge Base collection of articles is one of the advantages of subscribing to MySQL Enterprise. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlimport"></a>7.14. <span><strong class="command">mysqlimport</strong></span> — A Data Import Program</h2></div></div></div><p> The <span><strong class="command">mysqlimport</strong></span> client provides a command-line interface to the <code class="literal">LOAD DATA INFILE</code> SQL statement. Most options to <span><strong class="command">mysqlimport</strong></span> correspond directly to clauses of <code class="literal">LOAD DATA INFILE</code> syntax. See <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>. </p><p> Invoke <span><strong class="command">mysqlimport</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlimport [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>db_name</code></em> <em class="replaceable"><code>textfile1</code></em> [<em class="replaceable"><code>textfile2</code></em> ...]</code></strong> </pre><p> For each text file named on the command line, <span><strong class="command">mysqlimport</strong></span> strips any extension from the filename and uses the result to determine the name of the table into which to import the file's contents. For example, files named <code class="filename">patient.txt</code>, <code class="filename">patient.text</code>, and <code class="filename">patient</code> all would be imported into a table named <code class="literal">patient</code>. </p><p> <span><strong class="command">mysqlimport</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlimport_help"></a> <a class="indexterm" name="id2725926"></a> <a class="indexterm" name="id2725938"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlimport_character-sets-dir"></a> <a class="indexterm" name="id2725971"></a> <a class="indexterm" name="id2725983"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlimport_columns"></a> <a class="indexterm" name="id2726021"></a> <a class="indexterm" name="id2726033"></a> <code class="option">--columns=<em class="replaceable"><code>column_list</code></em></code>, <code class="option">-c <em class="replaceable"><code>column_list</code></em></code> </p><p> This option takes a comma-separated list of column names as its value. The order of the column names indicates how to match data file columns with table columns. </p></li><li><p><a name="option_mysqlimport_compress"></a> <a class="indexterm" name="id2726074"></a> <a class="indexterm" name="id2726086"></a> <code class="option">--compress</code>, <code class="option">-C</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysqlimport_debug"></a> <a class="indexterm" name="id2726120"></a> <a class="indexterm" name="id2726132"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_mysqlimport_default-character-set"></a> <a class="indexterm" name="id2726187"></a> <a class="indexterm" name="id2726200"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlimport_delete"></a> <a class="indexterm" name="id2726241"></a> <a class="indexterm" name="id2726254"></a> <code class="option">--delete</code>, <code class="option">-D</code> </p><p> Empty the table before importing the text file. </p></li><li><p><a name="option_mysqlimport_fields"></a> <a class="indexterm" name="id2726286"></a> <a class="indexterm" name="id2726299"></a> <code class="option">--fields-terminated-by=...</code>, <a class="indexterm" name="id2726316"></a> <a class="indexterm" name="id2726328"></a> <code class="option">--fields-enclosed-by=...</code>, <a class="indexterm" name="id2726345"></a> <a class="indexterm" name="id2726358"></a> <code class="option">--fields-optionally-enclosed-by=...</code>, <a class="indexterm" name="id2726375"></a> <a class="indexterm" name="id2726388"></a> <code class="option">--fields-escaped-by=...</code> </p><p> These options have the same meaning as the corresponding clauses for <code class="literal">LOAD DATA INFILE</code>. See <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>. </p></li><li><p><a name="option_mysqlimport_force"></a> <a class="indexterm" name="id2726430"></a> <a class="indexterm" name="id2726442"></a> <code class="option">--force</code>, <code class="option">-f</code> </p><p> Ignore errors. For example, if a table for a text file does not exist, continue processing any remaining files. Without <code class="option">--force</code>, <span><strong class="command">mysqlimport</strong></span> exits if a table does not exist. </p></li><li><p><a name="option_mysqlimport_host"></a> <a class="indexterm" name="id2726487"></a> <a class="indexterm" name="id2726499"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Import data to the MySQL server on the given host. The default host is <code class="literal">localhost</code>. </p></li><li><p><a name="option_mysqlimport_ignore"></a> <a class="indexterm" name="id2726544"></a> <a class="indexterm" name="id2726556"></a> <code class="option">--ignore</code>, <code class="option">-i</code> </p><p> See the description for the <code class="option">--replace</code> option. </p></li><li><p><a name="option_mysqlimport_ignore-lines"></a> <a class="indexterm" name="id2726593"></a> <a class="indexterm" name="id2726605"></a> <code class="option">--ignore-lines=<em class="replaceable"><code>N</code></em></code> </p><p> Ignore the first <em class="replaceable"><code>N</code></em> lines of the data file. </p></li><li><p><a name="option_mysqlimport_lines-terminated-by"></a> <a class="indexterm" name="id2726641"></a> <a class="indexterm" name="id2726653"></a> <code class="option">--lines-terminated-by=...</code> </p><p> This option has the same meaning as the corresponding clause for <code class="literal">LOAD DATA INFILE</code>. For example, to import Windows files that have lines terminated with carriage return/linefeed pairs, use <code class="option">--lines-terminated-by="\r\n"</code>. (You might have to double the backslashes, depending on the escaping conventions of your command interpreter.) See <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>. </p></li><li><p><a name="option_mysqlimport_local"></a> <a class="indexterm" name="id2726704"></a> <a class="indexterm" name="id2726716"></a> <code class="option">--local</code>, <code class="option">-L</code> </p><p> Read input files locally from the client host. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on the security implications of enabling <code class="literal">LOCAL</code>, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_mysqlimport_lock-tables"></a> <a class="indexterm" name="id2726776"></a> <a class="indexterm" name="id2726789"></a> <code class="option">--lock-tables</code>, <code class="option">-l</code> </p><p> Lock <span class="emphasis"><em>all</em></span> tables for writing before processing any text files. This ensures that all tables are synchronized on the server. </p></li><li><p><a name="option_mysqlimport_low-priority"></a> <a class="indexterm" name="id2726827"></a> <a class="indexterm" name="id2726839"></a> <code class="option">--low-priority</code> </p><p> Use <code class="literal">LOW_PRIORITY</code> when loading the table. This affects only storage engines that use only table-level locking (<code class="literal">MyISAM</code>, <code class="literal">MEMORY</code>, <code class="literal">MERGE</code>). </p></li><li><p><a name="option_mysqlimport_password"></a> <a class="indexterm" name="id2726894"></a> <a class="indexterm" name="id2726906"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlimport_port"></a> <a class="indexterm" name="id2726979"></a> <a class="indexterm" name="id2726991"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysqlimport_protocol"></a> <a class="indexterm" name="id2727029"></a> <a class="indexterm" name="id2727042"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqlimport_replace"></a> <a class="indexterm" name="id2727071"></a> <a class="indexterm" name="id2727084"></a> <code class="option">--replace</code>, <code class="option">-r</code> </p><p> The <code class="option">--replace</code> and <code class="option">--ignore</code> options control handling of input rows that duplicate existing rows on unique key values. If you specify <code class="option">--replace</code>, new rows replace existing rows that have the same unique key value. If you specify <code class="option">--ignore</code>, input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored. </p></li><li><p><a name="option_mysqlimport_silent"></a> <a class="indexterm" name="id2727139"></a> <a class="indexterm" name="id2727152"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Produce output only when errors occur. </p></li><li><p><a name="option_mysqlimport_socket"></a> <a class="indexterm" name="id2727184"></a> <a class="indexterm" name="id2727197"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqlimport_ssl"></a> <a class="indexterm" name="id2727242"></a> <a class="indexterm" name="id2727254"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysqlimport_user"></a> <a class="indexterm" name="id2727294"></a> <a class="indexterm" name="id2727307"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysqlimport_verbose"></a> <a class="indexterm" name="id2727345"></a> <a class="indexterm" name="id2727357"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_mysqlimport_version"></a> <a class="indexterm" name="id2727390"></a> <a class="indexterm" name="id2727403"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div><p> Here is a sample session that demonstrates use of <span><strong class="command">mysqlimport</strong></span>: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test</code></strong> shell> <strong class="userinput"><code>ed</code></strong> a 100 Max Sydow 101 Count Dracula . w imptest.txt 32 q shell> <strong class="userinput"><code>od -c imptest.txt</code></strong> 0000000 1 0 0 \t M a x S y d o w \n 1 0 0000020 1 \t C o u n t D r a c u l a \n 0000040 shell> <strong class="userinput"><code>mysqlimport --local test imptest.txt</code></strong> test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0 shell> <strong class="userinput"><code>mysql -e 'SELECT * FROM imptest' test</code></strong> +------+---------------+ | id | n | +------+---------------+ | 100 | Max Sydow | | 101 | Count Dracula | +------+---------------+ </pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlmanagerc"></a>7.15. <span><strong class="command">mysqlmanagerc</strong></span> — Internal Test-Suite Program</h2></div></div></div><p> This program was used internally for test purposes. As of MySQL 5.0, it is no longer used. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlmanager-pwgen"></a>7.16. <span><strong class="command">mysqlmanager-pwgen</strong></span> — Internal Test-Suite Program</h2></div></div></div><p> This program was used internally for test purposes. As of MySQL 5.0, it is no longer used. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysqlshow"></a>7.17. <span><strong class="command">mysqlshow</strong></span> — Display Database, Table, and Column Information</h2></div></div></div><p> The <span><strong class="command">mysqlshow</strong></span> client can be used to quickly see which databases exist, their tables, or a table's columns or indexes. </p><p> <span><strong class="command">mysqlshow</strong></span> provides a command-line interface to several SQL <code class="literal">SHOW</code> statements. See <a href="sql-syntax.html#show" title="12.5.4. SHOW Syntax">Section 12.5.4, “<code class="literal">SHOW</code> Syntax”</a>. The same information can be obtained by using those statements directly. For example, you can issue them from the <span><strong class="command">mysql</strong></span> client program. </p><p> Invoke <span><strong class="command">mysqlshow</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysqlshow [<em class="replaceable"><code>options</code></em>] [<em class="replaceable"><code>db_name</code></em> [<em class="replaceable"><code>tbl_name</code></em> [<em class="replaceable"><code>col_name</code></em>]]]</code></strong> </pre><div class="itemizedlist"><ul type="disc"><li><p> If no database is given, a list of database names is shown. </p></li><li><p> If no table is given, all matching tables in the database are shown. </p></li><li><p> If no column is given, all matching columns and column types in the table are shown. </p></li></ul></div><p> The output displays only the names of those databases, tables, or columns for which you have some privileges. </p><p> If the last argument contains shell or SQL wildcard characters (“<span class="quote"><code class="literal">*</code></span>”, “<span class="quote"><code class="literal">?</code></span>”, “<span class="quote"><code class="literal">%</code></span>”, or “<span class="quote"><code class="literal">_</code></span>”), only those names that are matched by the wildcard are shown. If a database name contains any underscores, those should be escaped with a backslash (some Unix shells require two) to get a list of the proper tables or columns. “<span class="quote"><code class="literal">*</code></span>” and “<span class="quote"><code class="literal">?</code></span>” characters are converted into SQL “<span class="quote"><code class="literal">%</code></span>” and “<span class="quote"><code class="literal">_</code></span>” wildcard characters. This might cause some confusion when you try to display the columns for a table with a “<span class="quote"><code class="literal">_</code></span>” in the name, because in this case, <span><strong class="command">mysqlshow</strong></span> shows you only the table names that match the pattern. This is easily fixed by adding an extra “<span class="quote"><code class="literal">%</code></span>” last on the command line as a separate argument. </p><p> <span><strong class="command">mysqlshow</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysqlshow_help"></a> <a class="indexterm" name="id2727762"></a> <a class="indexterm" name="id2727774"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysqlshow_character-sets-dir"></a> <a class="indexterm" name="id2727807"></a> <a class="indexterm" name="id2727820"></a> <code class="option">--character-sets-dir=<em class="replaceable"><code>path</code></em></code> </p><p> The directory where character sets are installed. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlshow_compress"></a> <a class="indexterm" name="id2727857"></a> <a class="indexterm" name="id2727870"></a> <code class="option">--compress</code>, <code class="option">-C</code> </p><p> Compress all information sent between the client and the server if both support compression. </p></li><li><p><a name="option_mysqlshow_count"></a> <a class="indexterm" name="id2727903"></a> <a class="indexterm" name="id2727916"></a> <code class="option">--count</code> </p><p> Show the number of rows per table. This can be slow for non-<code class="literal">MyISAM</code> tables. This option was added in MySQL 5.0.6. </p></li><li><p><a name="option_mysqlshow_debug"></a> <a class="indexterm" name="id2727953"></a> <a class="indexterm" name="id2727965"></a> <code class="option">--debug[=<em class="replaceable"><code>debug_options</code></em>]</code>, <code class="option">-# [<em class="replaceable"><code>debug_options</code></em>]</code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_mysqlshow_default-character-set"></a> <a class="indexterm" name="id2728020"></a> <a class="indexterm" name="id2728033"></a> <code class="option">--default-character-set=<em class="replaceable"><code>charset_name</code></em></code> </p><p> Use <em class="replaceable"><code>charset_name</code></em> as the default character set. See <a href="internationalization-localization.html#charset-configuration" title="9.2. The Character Set Used for Data and Sorting">Section 9.2, “The Character Set Used for Data and Sorting”</a>. </p></li><li><p><a name="option_mysqlshow_host"></a> <a class="indexterm" name="id2728074"></a> <a class="indexterm" name="id2728086"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysqlshow_keys"></a> <a class="indexterm" name="id2728124"></a> <a class="indexterm" name="id2728137"></a> <code class="option">--keys</code>, <code class="option">-k</code> </p><p> Show table indexes. </p></li><li><p><a name="option_mysqlshow_password"></a> <a class="indexterm" name="id2728169"></a> <a class="indexterm" name="id2728181"></a> <code class="option">--password[=<em class="replaceable"><code>password</code></em>]</code>, <code class="option">-p[<em class="replaceable"><code>password</code></em>]</code> </p><p> The password to use when connecting to the server. If you use the short option form (<code class="option">-p</code>), you <span class="emphasis"><em>cannot</em></span> have a space between the option and the password. If you omit the <em class="replaceable"><code>password</code></em> value following the <code class="option">--password</code> or <code class="option">-p</code> option on the command line, you are prompted for one. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysqlshow_port"></a> <a class="indexterm" name="id2728264"></a> <a class="indexterm" name="id2728276"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysqlshow_protocol"></a> <a class="indexterm" name="id2728314"></a> <a class="indexterm" name="id2728327"></a> <code class="option">--protocol={TCP|SOCKET|PIPE|MEMORY}</code> </p><p> The connection protocol to use. </p></li><li><p><a name="option_mysqlshow_show-table-type"></a> <a class="indexterm" name="id2728357"></a> <a class="indexterm" name="id2728369"></a> <code class="option">--show-table-type</code>, <code class="option">-t</code> </p><p> Show a column indicating the table type, as in <code class="literal">SHOW FULL TABLES</code>. The type is <code class="literal">BASE TABLE</code> or <code class="literal">VIEW</code>. This option was added in MySQL 5.0.4. </p></li><li><p><a name="option_mysqlshow_socket"></a> <a class="indexterm" name="id2728422"></a> <a class="indexterm" name="id2728434"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysqlshow_ssl"></a> <a class="indexterm" name="id2728479"></a> <a class="indexterm" name="id2728492"></a> <code class="option">--ssl*</code> </p><p> Options that begin with <code class="option">--ssl</code> specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See <a href="server-administration.html#ssl-options" title="5.8.7.3. SSL Command Options">Section 5.8.7.3, “SSL Command Options”</a>. </p></li><li><p><a name="option_mysqlshow_status"></a> <a class="indexterm" name="id2728532"></a> <a class="indexterm" name="id2728544"></a> <code class="option">--status</code>, <code class="option">-i</code> </p><p> Display extra information about each table. </p></li><li><p><a name="option_mysqlshow_user"></a> <a class="indexterm" name="id2728577"></a> <a class="indexterm" name="id2728589"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysqlshow_verbose"></a> <a class="indexterm" name="id2728627"></a> <a class="indexterm" name="id2728640"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. This option can be used multiple times to increase the amount of information. </p></li><li><p><a name="option_mysqlshow_version"></a> <a class="indexterm" name="id2728674"></a> <a class="indexterm" name="id2728687"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-convert-table-format"></a>7.18. <span><strong class="command">mysql_convert_table_format</strong></span> — Convert Tables to Use a Given Storage Engine</h2></div></div></div><p> <span><strong class="command">mysql_convert_table_format</strong></span> converts the tables in a database to use a particular storage engine (<code class="literal">MyISAM</code> by default). <span><strong class="command">mysql_convert_table_format</strong></span> is written in Perl and requires that the <code class="literal">DBI</code> and <code class="literal">DBD::mysql</code> Perl modules be installed (see <a href="installing.html#perl-support" title="2.4.21. Perl Installation Notes">Section 2.4.21, “Perl Installation Notes”</a>). </p><p> Invoke <span><strong class="command">mysql_convert_table_format</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_convert_table_format [<em class="replaceable"><code>options</code></em>]<em class="replaceable"><code>db_name</code></em></code></strong> </pre><p> The <em class="replaceable"><code>db_name</code></em> argument indicates the database containing the tables to be converted. </p><p> <span><strong class="command">mysql_convert_table_format</strong></span> understands the options described in the following list. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_convert_table_format_help"></a> <code class="option">--help</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_convert_table_format_force"></a> <code class="option">--force</code> </p><p> Continue even if errors occur. </p></li><li><p><a name="option_mysql_convert_table_format_host"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysql_convert_table_format_password"></a> <code class="option">--password=<em class="replaceable"><code>password</code></em></code> </p><p> The password to use when connecting to the server. Note that the password value is not optional for this option, unlike for other MySQL programs. You can use an option file to avoid giving the password on the command line. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysql_convert_table_format_port"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use. </p></li><li><p><a name="option_mysql_convert_table_format_type"></a> <code class="option">--type=<em class="replaceable"><code>engine_name</code></em></code> </p><p> Specify the storage engine that the tables should be converted to use. The default is <code class="literal">MyISAM</code> if this option is not given. </p><p class="mnmas"><b>MySQL Enterprise</b> For expert advice on choosing the optimum storage engine, subscribe to the MySQL Enterprise Monitor. For more information see <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>. </p></li><li><p><a name="option_mysql_convert_table_format_user"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li><li><p><a name="option_mysql_convert_table_format_verbose"></a> <code class="option">--verbose</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_mysql_convert_table_format_version"></a> <code class="option">--version</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-explain-log"></a>7.19. <span><strong class="command">mysql_explain_log</strong></span> — Use EXPLAIN on Statements in Query Log</h2></div></div></div><p> <span><strong class="command">mysql_explain_log</strong></span> reads its standard input for query log contents. It uses <code class="literal">EXPLAIN</code> to analyze <code class="literal">SELECT</code> statements found in the input. <code class="literal">UPDATE</code> statements are rewritten to <code class="literal">SELECT</code> statements and also analyzed with <code class="literal">EXPLAIN</code>. <span><strong class="command">mysql_explain_log</strong></span> then displays a summary of its results. </p><p> The results may assist you in determining which queries result in table scans and where it would be beneficial to add indexes to your tables. </p><p> Invoke <span><strong class="command">mysql_explain_log</strong></span> like this, where <em class="replaceable"><code>log_file</code></em> contains all or part of a MySQL query log: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_explain_log [<em class="replaceable"><code>options</code></em>] < <em class="replaceable"><code>log_file</code></em></code></strong> </pre><p> <span><strong class="command">mysql_explain_log</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_explain_log_help"></a> <a class="indexterm" name="id2729175"></a> <a class="indexterm" name="id2729188"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_explain_log_date"></a> <a class="indexterm" name="id2729220"></a> <a class="indexterm" name="id2729233"></a> <code class="option">--date=<em class="replaceable"><code>YYMMDD</code></em></code>, <code class="option">-d <em class="replaceable"><code>YYMMDD</code></em></code> </p><p> Select entries from the log only for the given date. </p></li><li><p><a name="option_mysql_explain_log_host"></a> <a class="indexterm" name="id2729271"></a> <a class="indexterm" name="id2729284"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysql_explain_log_password"></a> <a class="indexterm" name="id2729322"></a> <a class="indexterm" name="id2729334"></a> <code class="option">--password=<em class="replaceable"><code>password</code></em></code>, <code class="option">-p <em class="replaceable"><code>password</code></em></code> </p><p> The password to use when connecting to the server. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysql_explain_log_printerror"></a> <a class="indexterm" name="id2729383"></a> <a class="indexterm" name="id2729396"></a> <code class="option">--printerror=1</code>, <code class="option">-e 1</code> </p><p> Enable error output. </p></li><li><p><a name="option_mysql_explain_log_socket"></a> <a class="indexterm" name="id2729428"></a> <a class="indexterm" name="id2729441"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use, or, on Windows, the name of the named pipe to use. </p></li><li><p><a name="option_mysql_explain_log_user"></a> <a class="indexterm" name="id2729486"></a> <a class="indexterm" name="id2729499"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-find-rows"></a>7.20. <span><strong class="command">mysql_find_rows</strong></span> — Extract SQL Statements from Files</h2></div></div></div><p> <span><strong class="command">mysql_find_rows</strong></span> reads files containing SQL statements and extracts statements that match a given regular expression or that contain <code class="literal">USE <em class="replaceable"><code>db_name</code></em></code> or <code class="literal">SET</code> statements. The utility was written for use with update log files, but it can be used with other files that contain SQL statements. </p><p> Invoke <span><strong class="command">mysql_find_rows</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_find_rows [<em class="replaceable"><code>options</code></em>] [<em class="replaceable"><code>file_name</code></em> ...]</code></strong> </pre><p> Each <em class="replaceable"><code>file_name</code></em> argument should be the name of file containing SQL statements. If no filenames are given, <span><strong class="command">mysql_find_rows</strong></span> reads the standard input. </p><p> Examples: </p><pre class="programlisting">mysql_find_rows --regexp=problem_table --rows=20 < update.log mysql_find_rows --regexp=problem_table update-log.1 update-log.2 </pre><p> <span><strong class="command">mysql_find_rows</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_find_rows_help"></a> <a class="indexterm" name="id2729653"></a> <a class="indexterm" name="id2729666"></a> <code class="option">--help</code>, <code class="option">--Information</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_find_rows_regexp"></a> <a class="indexterm" name="id2729699"></a> <a class="indexterm" name="id2729712"></a> <code class="option">--regexp=<em class="replaceable"><code>pattern</code></em></code> </p><p> Display queries that match the pattern. </p></li><li><p><a name="option_mysql_find_rows_rows"></a> <a class="indexterm" name="id2729743"></a> <a class="indexterm" name="id2729756"></a> <code class="option">--rows=<em class="replaceable"><code>N</code></em></code> </p><p> Quit after displaying <em class="replaceable"><code>N</code></em> queries. </p></li><li><p><a name="option_mysql_find_rows_skip-use-db"></a> <a class="indexterm" name="id2729791"></a> <a class="indexterm" name="id2729804"></a> <code class="option">--skip-use-db</code> </p><p> Do not include <code class="literal">USE <em class="replaceable"><code>db_name</code></em></code> statements in the output. </p></li><li><p><a name="option_mysql_find_rows_start_row"></a> <a class="indexterm" name="id2729842"></a> <a class="indexterm" name="id2729855"></a> <code class="option">--start_row=<em class="replaceable"><code>N</code></em></code> </p><p> Start output from this row. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-fix-extensions"></a>7.21. <span><strong class="command">mysql_fix_extensions</strong></span> — Make Table Filename Extensions Lowercase</h2></div></div></div><p> <span><strong class="command">mysql_fix_extensions</strong></span> converts the extensions for <code class="literal">MyISAM</code> table files to lowercase. It looks for files with an extension that that matches any lettercase variant of <code class="filename">.frm</code>, <code class="filename">.myd</code>, <code class="filename">.myi</code>, <code class="filename">.isd</code>, and <code class="filename">.ism</code> and renames them to have extensionsn of <code class="filename">.frm</code>, <code class="filename">.MYD</code>, <code class="filename">.MYI</code>, <code class="filename">.ISD</code>, and <code class="filename">.ISM</code>, respectively. This can be useful after transferring the files from a system with case-insensitive filenames (such as Windows) to a system with case-sensitive filenames. </p><p> Invoke <span><strong class="command">mysql_fix_extensions</strong></span> like this, where <em class="replaceable"><code>data_dir</code></em> is the pathname to the MySQL data directory. </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_fix_extensions <em class="replaceable"><code>data_dir</code></em></code></strong> </pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-setpermission"></a>7.22. <span><strong class="command">mysql_setpermission</strong></span> — Interactively Set Permissions in Grant Tables</h2></div></div></div><p> <span><strong class="command">mysql_setpermission</strong></span> is a Perl script that was originally written and contributed by Luuk de Boer. It interactively sets permissions in the MySQL grant tables. <span><strong class="command">mysql_setpermission</strong></span> is written in Perl and requires that the <code class="literal">DBI</code> and <code class="literal">DBD::mysql</code> Perl modules be installed (see <a href="installing.html#perl-support" title="2.4.21. Perl Installation Notes">Section 2.4.21, “Perl Installation Notes”</a>). </p><p> Invoke <span><strong class="command">mysql_setpermission</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_setpermission [<em class="replaceable"><code>options</code></em>]</code></strong> </pre><p> <em class="replaceable"><code>options</code></em> should be either <code class="option">--help</code> to display the help message, or options that indicate how to connect to the MySQL server. The account used when you connect determines which permissions you have when attempting to modify existing permissions in the grant tables. </p><p> <span><strong class="command">mysql_setpermissions</strong></span> also reads options from the <code class="literal">[client]</code> and <code class="literal">[perl]</code> groups in the <code class="filename">.my.cnf</code> file in your home directory, if the file exists. </p><p> <span><strong class="command">mysql_setpermission</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_setpermission_help"></a> <a class="indexterm" name="id2730147"></a> <a class="indexterm" name="id2730159"></a> <code class="option">--help</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_setpermission_host"></a> <a class="indexterm" name="id2730189"></a> <a class="indexterm" name="id2730201"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysql_setpermission_password"></a> <a class="indexterm" name="id2730233"></a> <a class="indexterm" name="id2730246"></a> <code class="option">--password=<em class="replaceable"><code>password</code></em></code> </p><p> The password to use when connecting to the server. Note that the password value is not optional for this option, unlike for other MySQL programs. You can use an option file to avoid giving the password on the command line. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysql_setpermission_port"></a> <a class="indexterm" name="id2730292"></a> <a class="indexterm" name="id2730305"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysql_setpermission_socket"></a> <a class="indexterm" name="id2730337"></a> <a class="indexterm" name="id2730350"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code> </p><p> For connections to <code class="literal">localhost</code>, the Unix socket file to use. </p></li><li><p><a name="option_mysql_setpermission_user"></a> <a class="indexterm" name="id2730388"></a> <a class="indexterm" name="id2730400"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-tableinfo"></a>7.23. <span><strong class="command">mysql_tableinfo</strong></span> — Generate Database Metadata</h2></div></div></div><p> <span><strong class="command">mysql_tableinfo</strong></span> creates tables and populates them with database metadata. It uses <code class="literal">SHOW DATABASES</code>, <code class="literal">SHOW TABLES</code>, <code class="literal">SHOW TABLE STATUS</code>, <code class="literal">SHOW COLUMNS</code>, and <code class="literal">SHOW INDEX</code> to obtain the metadata. </p><p> In MySQL 5.0 and up, the <code class="literal">INFORMATION_SCHEMA</code> database contains the same kind of information in the <code class="literal">SCHEMATA</code>, <code class="literal">TABLES</code>, <code class="literal">COLUMNS</code>, and <code class="literal">STATISTICS</code> tables. See <a href="information-schema.html" title="Chapter 21. INFORMATION_SCHEMA Tables">Chapter 21, <i><code class="literal">INFORMATION_SCHEMA</code> Tables</i></a>. </p><p> Invoke <span><strong class="command">mysql_tableinfo</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_tableinfo [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>db_name</code></em> [<em class="replaceable"><code>db_like</code></em> [<em class="replaceable"><code>tbl_like</code></em>]]</code></strong> </pre><p> The <em class="replaceable"><code>db_name</code></em> argument indicates which database <span><strong class="command">mysql_tableinfo</strong></span> should use as the location for the metadata tables. The database will be created if it does not exist. The tables will be named <code class="literal">db</code>, <code class="literal">tbl</code> (or <code class="literal">tbl_status</code>), <code class="literal">col</code>, and <code class="literal">idx</code>. </p><p> If the <em class="replaceable"><code>db_like</code></em> or <em class="replaceable"><code>tbl_like</code></em> arguments are given, they are used as patterns and metadata is generated only for databases or tables that match the patterns. These arguments default to <code class="literal">%</code> if not given. </p><p> Examples: </p><pre class="programlisting">mysql_tableinfo info mysql_tableinfo info world mysql_tableinfo info mydb tmp% </pre><p> Each of the commands stores information into tables in the <code class="literal">info</code> database. The first stores information for all databases and tables. The second stores information for all tables in the <code class="literal">world</code> database. The third stores information for tables in the <code class="literal">mydb</code> database that have names matching the pattern <code class="literal">tmp%</code>. </p><p> <span><strong class="command">mysql_tableinfo</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_tableinfo_help"></a> <a class="indexterm" name="id2730686"></a> <a class="indexterm" name="id2730698"></a> <code class="option">--help</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_tableinfo_clear"></a> <a class="indexterm" name="id2730728"></a> <a class="indexterm" name="id2730741"></a> <code class="option">--clear</code> </p><p> Before populating each metadata table, drop it if it exists. </p></li><li><p><a name="option_mysql_tableinfo_clear-option"></a> <a class="indexterm" name="id2730771"></a> <a class="indexterm" name="id2730784"></a> <code class="option">--clear-only</code> </p><p> Similar to <code class="option">--clear</code>, but exits after dropping the metadata tables to be populated. </p></li><li><p><a name="option_mysql_tableinfo_col"></a> <a class="indexterm" name="id2730818"></a> <a class="indexterm" name="id2730830"></a> <code class="option">--col</code> </p><p> Generate column metadata into the <code class="literal">col</code> table. </p></li><li><p><a name="option_mysql_tableinfo_host"></a> <a class="indexterm" name="id2730865"></a> <a class="indexterm" name="id2730878"></a> <code class="option">--host=<em class="replaceable"><code>host_name</code></em></code>, <code class="option">-h <em class="replaceable"><code>host_name</code></em></code> </p><p> Connect to the MySQL server on the given host. </p></li><li><p><a name="option_mysql_tableinfo_idx"></a> <a class="indexterm" name="id2730916"></a> <a class="indexterm" name="id2730928"></a> <code class="option">--idx</code> </p><p> Generate index metadata into the <code class="literal">idx</code> table. </p></li><li><p><a name="option_mysql_tableinfo_password"></a> <a class="indexterm" name="id2730964"></a> <a class="indexterm" name="id2730976"></a> <code class="option">--password=<em class="replaceable"><code>password</code></em></code>, <code class="option">-p<em class="replaceable"><code>password</code></em></code> </p><p> The password to use when connecting to the server. Note that the password value is not optional for this option, unlike for other MySQL programs. You can use an option file to avoid giving the password on the command line. </p><p> Specifying a password on the command line should be considered insecure. See <a href="server-administration.html#password-security" title="5.8.6. Keeping Your Password Secure">Section 5.8.6, “Keeping Your Password Secure”</a>. </p></li><li><p><a name="option_mysql_tableinfo_port"></a> <a class="indexterm" name="id2731028"></a> <a class="indexterm" name="id2731041"></a> <code class="option">--port=<em class="replaceable"><code>port_num</code></em></code>, <code class="option">-P <em class="replaceable"><code>port_num</code></em></code> </p><p> The TCP/IP port number to use for the connection. </p></li><li><p><a name="option_mysql_tableinfo_prefix"></a> <a class="indexterm" name="id2731079"></a> <a class="indexterm" name="id2731092"></a> <code class="option">--prefix=<em class="replaceable"><code>prefix_str</code></em></code> </p><p> Add <em class="replaceable"><code>prefix_str</code></em> at the beginning of each metadata table name. </p></li><li><p><a name="option_mysql_tableinfo_quiet"></a> <a class="indexterm" name="id2731128"></a> <a class="indexterm" name="id2731140"></a> <code class="option">--quiet</code>, <code class="option">-q</code> </p><p> Be silent except for errors. </p></li><li><p><a name="option_mysql_tableinfo_socket"></a> <a class="indexterm" name="id2731173"></a> <a class="indexterm" name="id2731186"></a> <code class="option">--socket=<em class="replaceable"><code>path</code></em></code>, <code class="option">-S <em class="replaceable"><code>path</code></em></code> </p><p> The Unix socket file to use for the connection. </p></li><li><p><a name="option_mysql_tableinfo_tbl-status"></a> <a class="indexterm" name="id2731224"></a> <a class="indexterm" name="id2731236"></a> <code class="option">--tbl-status</code> </p><p> Use <code class="literal">SHOW TABLE STATUS</code> instead of <code class="literal">SHOW TABLES</code>. This provides more complete information, but is slower. </p></li><li><p><a name="option_mysql_tableinfo_user"></a> <a class="indexterm" name="id2731279"></a> <a class="indexterm" name="id2731291"></a> <code class="option">--user=<em class="replaceable"><code>user_name</code></em></code>, <code class="option">-u <em class="replaceable"><code>user_name</code></em></code> </p><p> The MySQL username to use when connecting to the server. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-waitpid"></a>7.24. <span><strong class="command">mysql_waitpid</strong></span> — Kill Process and Wait for Its Termination</h2></div></div></div><p> <span><strong class="command">mysql_waitpid</strong></span> signals a process to terminate and waits for the process to exit. It uses the <code class="literal">kill()</code> system call and Unix signals, so it runs on Unix and Unix-like systems. </p><p> Invoke <span><strong class="command">mysql_waitpid</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_waitpid [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>pid</code></em> <em class="replaceable"><code>wait_time</code></em></code></strong> </pre><p> <span><strong class="command">mysql_waitpid</strong></span> sends signal 0 to the process identified by <em class="replaceable"><code>pid</code></em> and waits up to <em class="replaceable"><code>wait_time</code></em> seconds for the process to terminate. <em class="replaceable"><code>pid</code></em> and <em class="replaceable"><code>wait_time</code></em> must be positive integers. </p><p> If process termination occurs within the wait time or the process does not exist, <span><strong class="command">mysql_waitpid</strong></span> returns 0. Otherwise, it returns 1. </p><p> If the <code class="literal">kill()</code> system call cannot handle signal 0, <span><strong class="command">mysql_waitpid()</strong></span> uses signal 1 instead. </p><p> <span><strong class="command">mysql_waitpid</strong></span> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_waitpid_help"></a> <a class="indexterm" name="id2731462"></a> <a class="indexterm" name="id2731474"></a> <code class="option">--help</code>, <code class="option">-?</code>, <code class="option">-I</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_waitpid_verbose"></a> <a class="indexterm" name="id2731511"></a> <a class="indexterm" name="id2731523"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Display a warning if signal 0 could not be used and signal 1 is used instead. </p></li><li><p><a name="option_mysql_waitpid_version"></a> <a class="indexterm" name="id2731557"></a> <a class="indexterm" name="id2731570"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="mysql-zap"></a>7.25. <span><strong class="command">mysql_zap</strong></span> — Kill Processes That Match a Pattern</h2></div></div></div><p> <span><strong class="command">mysql_zap</strong></span> kills processes that match a pattern. It uses the <span><strong class="command">ps</strong></span> command and Unix signals, so it runs on Unix and Unix-like systems. </p><p> Invoke <span><strong class="command">mysql_zap</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_zap [-<em class="replaceable"><code>signal</code></em>] [-?Ift] <em class="replaceable"><code>pattern</code></em></code></strong> </pre><p> A process matches if its output line from the <span><strong class="command">ps</strong></span> command contains the pattern. By default, <span><strong class="command">mysql_zap</strong></span> asks for confirmation for each process. Respond <code class="literal">y</code> to kill the process, or <code class="literal">q</code> to exit <span><strong class="command">mysql_zap</strong></span>. For any other response, <span><strong class="command">mysql_zap</strong></span> does not attempt to kill the process. </p><p> If the <code class="option">-<em class="replaceable"><code>signal</code></em></code> option is given, it specifies the name or number of the signal to send to each process. Otherwise, <span><strong class="command">mysql_zap</strong></span> tries first with <code class="literal">TERM</code> (signal 15) and then with <code class="literal">KILL</code> (signal 9). </p><p> <span><strong class="command">mysql_zap</strong></span> understands the following additional options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_mysql_zap_help"></a> <code class="option">--help</code>, <code class="option">-?</code>, <code class="option">-I</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_mysql_zap_force"></a> <code class="option">-f</code> </p><p> Force mode. <span><strong class="command">mysql_zap</strong></span> attempts to kill each process without confirmation. </p></li><li><p><a name="option_mysql_zap_test"></a> <code class="option">-t</code> </p><p> Test mode. Display information about each process but do not kill it. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="perror"></a>7.26. <span><strong class="command">perror</strong></span> — Explain Error Codes</h2></div></div></div><p> For most system errors, MySQL displays, in addition to an internal text message, the system error code in one of the following styles: </p><pre class="programlisting">message ... (errno: #) message ... (Errcode: #) </pre><p> You can find out what the error code means by examining the documentation for your system or by using the <span><strong class="command">perror</strong></span> utility. </p><p> <span><strong class="command">perror</strong></span> prints a description for a system error code or for a storage engine (table handler) error code. </p><p> Invoke <span><strong class="command">perror</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>perror [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>errorcode</code></em> ...</code></strong> </pre><p> Example: </p><pre class="programlisting">shell> <strong class="userinput"><code>perror 13 64</code></strong> OS error code 13: Permission denied OS error code 64: Machine is not on the network </pre><p> To obtain the error message for a MySQL Cluster error code, invoke <span><strong class="command">perror</strong></span> with the <code class="option">--ndb</code> option: </p><pre class="programlisting">shell> <strong class="userinput"><code>perror --ndb <em class="replaceable"><code>errorcode</code></em></code></strong> </pre><p> Note that the meaning of system error messages may be dependent on your operating system. A given error code may mean different things on different operating systems. </p><p> <span><strong class="command">perror</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_perror_help"></a> <a class="indexterm" name="id2731956"></a> <a class="indexterm" name="id2731969"></a> <code class="option">--help</code>, <code class="option">--info</code>, <code class="option">-I</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_perror_ndb"></a> <a class="indexterm" name="id2732008"></a> <a class="indexterm" name="id2732020"></a> <code class="option">--ndb</code> </p><p> Print the error message for a MySQL Cluster error code. </p></li><li><p><a name="option_perror_silent"></a> <a class="indexterm" name="id2732050"></a> <a class="indexterm" name="id2732062"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Print only the error message. </p></li><li><p><a name="option_perror_verbose"></a> <a class="indexterm" name="id2732095"></a> <a class="indexterm" name="id2732108"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print error code and message. This is the default behavior. </p></li><li><p><a name="option_perror_version"></a> <a class="indexterm" name="id2732141"></a> <a class="indexterm" name="id2732153"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="replace-utility"></a>7.27. <span><strong class="command">replace</strong></span> — A String-Replacement Utility</h2></div></div></div><p> The <span><strong class="command">replace</strong></span> utility program changes strings in place in files or on the standard input. </p><p> Invoke <span><strong class="command">replace</strong></span> in one of the following ways: </p><pre class="programlisting">shell> <strong class="userinput"><code>replace <em class="replaceable"><code>from</code></em> <em class="replaceable"><code>to</code></em> [<em class="replaceable"><code>from</code></em> <em class="replaceable"><code>to</code></em>] ... -- <em class="replaceable"><code>file</code></em> [<em class="replaceable"><code>file</code></em>] ...</code></strong> shell> <strong class="userinput"><code>replace <em class="replaceable"><code>from</code></em> <em class="replaceable"><code>to</code></em> [<em class="replaceable"><code>from</code></em> <em class="replaceable"><code>to</code></em>] ... < <em class="replaceable"><code>file</code></em></code></strong> </pre><p> <em class="replaceable"><code>from</code></em> represents a string to look for and <em class="replaceable"><code>to</code></em> represents its replacement. There can be one or more pairs of strings. </p><p> Use the <code class="option">--</code> option to indicate where the string-replacement list ends and the filenames begin. In this case, any file named on the command line is modified in place, so you may want to make a copy of the original before converting it. <em class="replaceable"><code>replace</code></em> prints a message indicating which of the input files it actually modifies. </p><p> If the <code class="option">--</code> option is not given, <span><strong class="command">replace</strong></span> reads the standard input and writes to the standard output. </p><p> <span><strong class="command">replace</strong></span> uses a finite state machine to match longer strings first. It can be used to swap strings. For example, the following command swaps <code class="literal">a</code> and <code class="literal">b</code> in the given files, <code class="filename">file1</code> and <code class="filename">file2</code>: </p><pre class="programlisting">shell> <strong class="userinput"><code>replace a b b a -- file1 file2 ...</code></strong> </pre><p> The <span><strong class="command">replace</strong></span> program is used by <span><strong class="command">msql2mysql</strong></span>. See <a href="client-utility-programs.html#msql2mysql" title="7.30.1. msql2mysql — Convert mSQL Programs for Use with MySQL">Section 7.30.1, “<span><strong class="command">msql2mysql</strong></span> — Convert mSQL Programs for Use with MySQL”</a>. </p><p> <span><strong class="command">replace</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_replace_help"></a> <code class="option">-?</code>, <code class="option">-I</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_replace_debug"></a> <code class="option">-# <em class="replaceable"><code>debug_options</code></em></code> </p><p> Write a debugging log. The <code class="literal"><em class="replaceable"><code>debug_options</code></em></code> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. </p></li><li><p><a name="option_replace_silent"></a> <code class="option">-s</code> </p><p> Silent mode. Print less information what the program does. </p></li><li><p><a name="option_replace_verbose"></a> <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_replace_version"></a> <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="resolveip"></a>7.28. <span><strong class="command">resolveip</strong></span> — Resolve Hostname to IP Address or Vice Versa</h2></div></div></div><p> The <span><strong class="command">resolveip</strong></span> utility resolves hostnames to IP addresses and vice versa. </p><p> Invoke <span><strong class="command">resolveip</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>resolveip [<em class="replaceable"><code>options</code></em>] {<em class="replaceable"><code>host_name</code></em>|<em class="replaceable"><code>ip-addr</code></em>} ...</code></strong> </pre><p> <span><strong class="command">resolveip</strong></span> understands the options described in the following list. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_resolveip_help"></a> <a class="indexterm" name="id2732579"></a> <a class="indexterm" name="id2732591"></a> <code class="option">--help</code>, <code class="option">-info</code>, <code class="option">-?</code>, <code class="option">-I</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_resolveip_silent"></a> <a class="indexterm" name="id2732630"></a> <a class="indexterm" name="id2732643"></a> <code class="option">--silent</code>, <code class="option">-s</code> </p><p> Silent mode. Produce less output. </p></li><li><p><a name="option_resolveip_version"></a> <a class="indexterm" name="id2732676"></a> <a class="indexterm" name="id2732688"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="resolve-stack-dump"></a>7.29. <span><strong class="command">resolve_stack_dump</strong></span> — Resolve Numeric Stack Trace Dump to Symbols</h2></div></div></div><p> <span><strong class="command">resolve_stack_dump</strong></span> resolves a numeric stack dump to symbols. </p><p> Invoke <span><strong class="command">resolve_stack_dump</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>resolve_stack_dump [<em class="replaceable"><code>options</code></em>] <em class="replaceable"><code>symbols_file</code></em> [<em class="replaceable"><code>numeric_dump_file</code></em>]</code></strong> </pre><p> The symbols file should include the output from the <span><strong class="command">nm --numeric-sort mysqld</strong></span> command. The numeric dump file should contain a numeric stack track from <span><strong class="command">mysqld</strong></span>. If no numeric dump file is named on the command line, the stack trace is read from the standard input. </p><p> <span><strong class="command">resolve_stack_dump</strong></span> understands the options described in the following list. </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_resolve_stack_dump_help"></a> <a class="indexterm" name="id2732812"></a> <a class="indexterm" name="id2732825"></a> <code class="option">--help</code>, <code class="option">-h</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_resolve_stack_dump_numeric-dump-file"></a> <a class="indexterm" name="id2732857"></a> <a class="indexterm" name="id2732870"></a> <code class="option">--numeric-dump-file=<em class="replaceable"><code>file_name</code></em></code>, <code class="option">-n <em class="replaceable"><code>file_name</code></em></code> </p><p> Read the stack trace from the given file. </p></li><li><p><a name="option_resolve_stack_dump_symbols-file"></a> <a class="indexterm" name="id2732909"></a> <a class="indexterm" name="id2732922"></a> <code class="option">--symbols-file=<em class="replaceable"><code>file_name</code></em></code>, <code class="option">-s <em class="replaceable"><code>file_name</code></em></code> </p><p> Use the given symbols file. </p></li><li><p><a name="option_resolve_stack_dump_version"></a> <a class="indexterm" name="id2732960"></a> <a class="indexterm" name="id2732972"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="programming-utilities"></a>7.30. MySQL Program Development Utilities</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="client-utility-programs.html#msql2mysql">7.30.1. <span><strong class="command">msql2mysql</strong></span> — Convert mSQL Programs for Use with MySQL</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#mysql-config">7.30.2. <span><strong class="command">mysql_config</strong></span> — Get Compile Options for Compiling Clients</a></span></dt><dt><span class="section"><a href="client-utility-programs.html#my-print-defaults">7.30.3. <span><strong class="command">my_print_defaults</strong></span> — Display Options from Option Files</a></span></dt></dl></div><p> This section describes some utilities that you may find useful when developing MySQL programs. </p><div class="itemizedlist"><ul type="disc"><li><p> <span><strong class="command">msql2mysql</strong></span> </p><p> A shell script that converts <code class="literal">mSQL</code> programs to MySQL. It doesn't handle every case, but it gives a good start when converting. </p></li><li><p> <span><strong class="command">mysql_config</strong></span> </p><p> A shell script that produces the option values needed when compiling MySQL programs. </p></li><li><p> <a class="indexterm" name="id2733062"></a> <span><strong class="command">my_print_defaults</strong></span> </p><p> A utility that shows which options are present in option groups of option files. See <a href="client-utility-programs.html#my-print-defaults" title="7.30.3. my_print_defaults — Display Options from Option Files">Section 7.30.3, “<span><strong class="command">my_print_defaults</strong></span> — Display Options from Option Files”</a>. </p></li></ul></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="msql2mysql"></a>7.30.1. <span><strong class="command">msql2mysql</strong></span> — Convert mSQL Programs for Use with MySQL</h3></div></div></div><p> Initially, the MySQL C API was developed to be very similar to that for the mSQL database system. Because of this, mSQL programs often can be converted relatively easily for use with MySQL by changing the names of the C API functions. </p><p> The <span><strong class="command">msql2mysql</strong></span> utility performs the conversion of mSQL C API function calls to their MySQL equivalents. <span><strong class="command">msql2mysql</strong></span> converts the input file in place, so make a copy of the original before converting it. For example, use <span><strong class="command">msql2mysql</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>cp client-prog.c client-prog.c.orig</code></strong> shell> <strong class="userinput"><code>msql2mysql client-prog.c</code></strong> client-prog.c converted </pre><p> Then examine <code class="filename">client-prog.c</code> and make any post-conversion revisions that may be necessary. </p><p> <span><strong class="command">msql2mysql</strong></span> uses the <span><strong class="command">replace</strong></span> utility to make the function name substitutions. See <a href="client-utility-programs.html#replace-utility" title="7.27. replace — A String-Replacement Utility">Section 7.27, “<span><strong class="command">replace</strong></span> — A String-Replacement Utility”</a>. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-config"></a>7.30.2. <span><strong class="command">mysql_config</strong></span> — Get Compile Options for Compiling Clients</h3></div></div></div><p> <span><strong class="command">mysql_config</strong></span> provides you with useful information for compiling your MySQL client and connecting it to MySQL. </p><p> <span><strong class="command">mysql_config</strong></span> supports the following options: </p><div class="itemizedlist"><ul type="disc"><li><p> <code class="option">--cflags</code> </p><p> Compiler flags to find include files and critical compiler flags and defines used when compiling the <code class="literal">libmysqlclient</code> library. </p></li><li><p> <code class="option">--include</code> </p><p> Compiler options to find MySQL include files. (Note that normally you would use <code class="option">--cflags</code> instead of this option.) </p></li><li><p> <code class="option">--libmysqld-libs</code>, <code class="option">--embedded</code> </p><p> Libraries and options required to link with the MySQL embedded server. </p></li><li><p> <code class="option">--libs</code> </p><p> Libraries and options required to link with the MySQL client library. </p></li><li><p> <code class="option">--libs_r</code> </p><p> Libraries and options required to link with the thread-safe MySQL client library. </p></li><li><p> <code class="option">--port</code> </p><p> The default TCP/IP port number, defined when configuring MySQL. </p></li><li><p> <code class="option">--socket</code> </p><p> The default Unix socket file, defined when configuring MySQL. </p></li><li><p> <code class="option">--version</code> </p><p> Version number for the MySQL distribution. </p></li></ul></div><p> If you invoke <span><strong class="command">mysql_config</strong></span> with no options, it displays a list of all options that it supports, and their values: </p><pre class="programlisting">shell> <strong class="userinput"><code>mysql_config</code></strong> Usage: /usr/local/mysql/bin/mysql_config [options] Options: --cflags [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro] --include [-I/usr/local/mysql/include/mysql] --libs [-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto] --libs_r [-L/usr/local/mysql/lib/mysql -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm -lpthread] --socket [/tmp/mysql.sock] --port [3306] --version [4.0.16] --libmysqld-libs [-L/usr/local/mysql/lib/mysql -lmysqld -lpthread -lz -lcrypt -lnsl -lm -lpthread -lrt] </pre><p> You can use <span><strong class="command">mysql_config</strong></span> within a command line to include the value that it displays for a particular option. For example, to compile a MySQL client program, use <span><strong class="command">mysql_config</strong></span> as follows: </p><pre class="programlisting">shell> <strong class="userinput"><code>CFG=/usr/local/mysql/bin/mysql_config</code></strong> shell> <strong class="userinput"><code>sh -c "gcc -o progname `$CFG --cflags` progname.c `$CFG --libs`"</code></strong> </pre><p> When you use <span><strong class="command">mysql_config</strong></span> this way, be sure to invoke it within backtick (“<span class="quote"><code class="literal">`</code></span>”) characters. That tells the shell to execute it and substitute its output into the surrounding command. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="my-print-defaults"></a>7.30.3. <span><strong class="command">my_print_defaults</strong></span> — Display Options from Option Files</h3></div></div></div><p> <span><strong class="command">my_print_defaults</strong></span> displays the options that are present in option groups of option files. The output indicates what options will be used by programs that read the specified option groups. For example, the <span><strong class="command">mysqlcheck</strong></span> program reads the <code class="literal">[mysqlcheck]</code> and <code class="literal">[client]</code> option groups. To see what options are present in those groups in the standard option files, invoke <span><strong class="command">my_print_defaults</strong></span> like this: </p><pre class="programlisting">shell> <strong class="userinput"><code>my_print_defaults mysqlcheck client</code></strong> --user=myusername --password=secret --host=localhost </pre><p> The output consists of options, one per line, in the form that they would be specified on the command line. </p><p> <code class="literal">my_print_defaults</code> understands the following options: </p><div class="itemizedlist"><ul type="disc"><li><p><a name="option_my_print_defaults_help"></a> <a class="indexterm" name="id2733549"></a> <a class="indexterm" name="id2733562"></a> <code class="option">--help</code>, <code class="option">-?</code> </p><p> Display a help message and exit. </p></li><li><p><a name="option_my_print_defaults_config-file"></a> <a class="indexterm" name="id2733595"></a> <a class="indexterm" name="id2733607"></a> <code class="option">--config-file=<em class="replaceable"><code>file_name</code></em></code>, <a class="indexterm" name="id2733626"></a> <a class="indexterm" name="id2733639"></a> <code class="option">--defaults-file=<em class="replaceable"><code>file_name</code></em></code>, <code class="option">-c <em class="replaceable"><code>file_name</code></em></code> </p><p> Read only the given option file. </p></li><li><p><a name="option_my_print_defaults_debug"></a> <a class="indexterm" name="id2733677"></a> <a class="indexterm" name="id2733690"></a> <code class="option">--debug=<em class="replaceable"><code>debug_options</code></em>, -# <em class="replaceable"><code>debug_options</code></em></code> </p><p> Write a debugging log. The <em class="replaceable"><code>debug_options</code></em> string often is <code class="literal">'d:t:o,<em class="replaceable"><code>file_name</code></em>'</code>. The default is <code class="literal">'d:t:o,/tmp/my_print_defaults.trace'</code>. </p></li><li><p><a name="option_my_print_defaults_defaults-extra-file"></a> <a class="indexterm" name="id2733748"></a> <a class="indexterm" name="id2733760"></a> <code class="option">--defaults-extra-file=<em class="replaceable"><code>file_name</code></em></code>, <a class="indexterm" name="id2733780"></a> <a class="indexterm" name="id2733792"></a> <code class="option">--extra-file=<em class="replaceable"><code>file_name</code></em></code>, <code class="option">-e <em class="replaceable"><code>file_name</code></em></code> </p><p> Read this option file after the global option file but (on Unix) before the user option file. </p></li><li><p><a name="option_my_print_defaults_defaults-group-suffix"></a> <a class="indexterm" name="id2733832"></a> <a class="indexterm" name="id2733845"></a> <code class="option">--defaults-group-suffix=<em class="replaceable"><code>suffix</code></em></code>, <code class="option">-g <em class="replaceable"><code>suffix</code></em></code> </p><p> In addition to the groups named on the command line, read groups that have the given suffix. </p></li><li><p><a name="option_my_print_defaults_no-defaults"></a> <a class="indexterm" name="id2733885"></a> <a class="indexterm" name="id2733898"></a> <code class="option">--no-defaults</code>, <code class="option">-n</code> </p><p> Return an empty string. </p></li><li><p><a name="option_my_print_defaults_verbose"></a> <a class="indexterm" name="id2733931"></a> <a class="indexterm" name="id2733943"></a> <code class="option">--verbose</code>, <code class="option">-v</code> </p><p> Verbose mode. Print more information about what the program does. </p></li><li><p><a name="option_my_print_defaults_version"></a> <a class="indexterm" name="id2733977"></a> <a class="indexterm" name="id2733990"></a> <code class="option">--version</code>, <code class="option">-V</code> </p><p> Display version information and exit. </p></li></ul></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="optimization.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="language-structure.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 6. Optimization </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 8. Language Structure</td></tr></table></div></body></html>