---
title: "转贴：Mysql 数据导入(import)/导出(export)- mysqldump命令"
author: "uu4u"
date: "2011-03-09T21:16:20Z"
tags: []
categories: ["数据库"]
slug: "mysql-import-export-mysqldump"
draft: false
lastmod: "2011-03-09T21:17:59Z"
id: 949287
url: "https://uu4u.iteye.com/blog/949287"
---

原文来自:http://www.clockwatchers.com/mysql\_dump.html

**MySQL Tutorial - Import or Export A Database**

This tutorial section deals with mysqldump which is a tool to import and export MySQL databases.

It can be used to back up a database or to move database information from one server to another.

**1. Export A MySQL Database**

This example shows you how to export a database. It is a good idea to export your data often as a backup.

\# mysqldump -u username -ppassword database\_name &gt; FILE.sql

 

Replace username, password and database\_name with your MySQL username, password and database name.

File FILE.sql now holds a backup of your database, download it to your computer.

**2. Import A MySQL Database**

Here, we import a database. Use this to restore data from a backup or to import from another MySQL server.

Start by uploading the FILE.sql file to the server where you will be running this command.

\# mysql -u username -ppassword database\_name &lt; FILE.sql

Replace the parts in red with your own information.

This powerful, easy to use command has many uses. Let's say you wanted to switch web hosting providers.

Simply export your data on the old provider's server and import it on your account with the new host.

 

 

 

###########################################################