uTools-Manuals/docs/linux/mysqldump.html
2019-04-21 11:50:48 +08:00

35 lines
2.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="mysqldump">mysqldump</h1>
<p>MySQL数据库中备份工具</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>mysqldump命令</strong> 是mysql数据库中备份工具用于将MySQL服务器中的数据库以标准的sql语言的方式导出并保存到文件中。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">mysqldump(选项)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">--add-drop-table在每个创建数据库表语句前添加删除数据库表的语句
--add-locks备份数据库表时锁定数据库表
--all-databases备份MySQL服务器上的所有数据库
--comments添加注释信息
--compact压缩模式产生更少的输出
--complete-insert输出完成的插入语句
--databases指定要备份的数据库
--default-character-set指定默认字符集
--force当出现错误时仍然继续备份操作
--host指定要备份数据库的服务器
--lock-tables备份前锁定所有数据库表
--no-create-db禁止生成创建数据库语句
--no-create-info禁止生成创建数据库库表语句
--password连接MySQL服务器的密码
--portMySQL服务器的端口号
--user连接MySQL服务器的用户名。</code></pre>
<h3 id="实例">实例</h3>
<p><strong>导出整个数据库</strong></p>
<pre><code class="language-bash">mysqldump -u 用户名 -p 数据库名 &gt; 导出的文件名
mysqldump -u linuxde -p smgp_apps_linuxde &gt; linuxde.sql</code></pre>
<p><strong>导出一个表</strong></p>
<pre><code class="language-bash">mysqldump -u 用户名 -p 数据库名 表名&gt; 导出的文件名
mysqldump -u linuxde -p smgp_apps_linuxde users &gt; linuxde_users.sql</code></pre>
<p><strong>导出一个数据库结构</strong></p>
<pre><code class="language-bash">mysqldump -u linuxde -p -d --add-drop-table smgp_apps_linuxde &gt; linuxde_db.sql</code></pre>
<p><code>-d</code>没有数据,<code>--add-drop-tabl</code>e每个create语句之前增加一个<code>drop table</code></p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->