Home Database Mysql Tutorial mysqldump命令导出数据用法详解

mysqldump命令导出数据用法详解

Jun 07, 2016 pm 05:52 PM
Data output

在平时的mysql应用中,总会碰到导入数据,导出数据,当然有很多方法,这篇文章,主要介绍应用mysqlmysqldump命令进行数据导入导出,希望对大家有所帮助。

mysqldump命令中带有一个 --where/-w 参数,它用来设定数据导出的条件,使用方式和SQL查询命令中中的where基本上相同,有了它,我们就可以从数据库中导出你需要的那部分数据了。

1.命令格式如下:

mysqldump -u用户名 -p密码 数据库名 表名 --where="筛选条件" > 导出文件路径

例子:

从test数据库的test_data表中导出id大于100的数据到 /tmp/test.sql 这个文件中

 代码如下 复制代码

mysqldump -uroot -p123456 test test_data --where=" id > 100" > /tmp/test.sql


2.导出整个数据库

mysqldump -u 用户名 -p 数据库名 > 导出的文件名

 代码如下 复制代码

mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql


3.导出一个数据库结构

 代码如下 复制代码

mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d 没有数据 --add-drop-table 在每个create语句之前增加一个drop table


导出库表(mysqldump)条件

mysqldump -u用户名 -p密码 -h主机 数据库 a -w “sql条件” –lock-all-tables > 路径

 代码如下 复制代码

1 mysqldump -hhostname -uusername -p dbname tbname>xxxx.sql
** 按指定条件导出数据库表内容。(-w选项 –where)

1 mysqldump -hhostname -uusername-p dbname tbname -w'id >= 1 and id xxxx.sql

1 mysqldump -hhostname -uusername -p dbname tbname --where='unit_id >= 1 and unit_id ~/xxxx.sql

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ECharts and Java interface: how to export and share statistical chart data ECharts and Java interface: how to export and share statistical chart data Dec 17, 2023 am 08:44 AM

ECharts is a powerful, flexible and customizable open source chart library that can be used for data visualization and large-screen display. In the era of big data, the data export and sharing functions of statistical charts have become increasingly important. This article will introduce how to implement the statistical chart data export and sharing functions of ECharts through the Java interface, and provide specific code examples. 1. Introduction to ECharts ECharts is a data visualization library based on JavaScript and Canvas open sourced by Baidu, with rich charts.

How to use vue and Element-plus to export and print data How to use vue and Element-plus to export and print data Jul 18, 2023 am 09:13 AM

How to use Vue and ElementPlus to implement data export and print functions. In recent years, with the rapid development of front-end development, more and more web applications need to provide data export and print functions to meet users' diverse needs for data use. As a popular JavaScript framework, Vue can easily implement data export and printing functions when used with the ElementPlus component library. This article will introduce a data export and

How to use PHP to implement data import and export Excel functions How to use PHP to implement data import and export Excel functions Sep 06, 2023 am 10:06 AM

How to use PHP to implement data import and export Excel functions. Importing and exporting Excel files is one of the common needs in web development. By using the PHP language, we can easily implement this function. In this article, we will introduce how to use PHP and the PHPExcel library to implement data import and export functions into Excel files. First, we need to install the PHPExcel library. You can download it from the official website (https://github.com/PHPOffice/P

PHP form processing: form data export and printing PHP form processing: form data export and printing Aug 09, 2023 pm 03:48 PM

PHP form processing: form data export and printing In website development, forms are an indispensable part. When a form on the website is filled out and submitted by the user, the developer needs to process the form data. This article will introduce how to use PHP to process form data, and demonstrate how to export the data to an Excel file and print it out. 1. Form submission and basic processing First, you need to create an HTML form for users to fill in and submit data. Let's say we have a simple feedback form with name, email, and comments. HTM

How to use Vue and Element-UI to implement data import and export functions How to use Vue and Element-UI to implement data import and export functions Jul 22, 2023 pm 01:25 PM

How to use Vue and Element-UI to implement data import and export functions. In recent years, with the development of web applications, data import and export functions have become more and more important in many projects. Providing users with convenient data import and export functions can not only improve the user experience, but also improve the overall efficiency of the system. This article will introduce how to use Vue and Element-UI to implement data import and export functions, and attach corresponding code examples. 1. Preparation work First, we need to introduce Vu into the project

The perfect combination of Vue and Excel: how to export data in batches The perfect combination of Vue and Excel: how to export data in batches Jul 21, 2023 pm 12:13 PM

The perfect combination of Vue and Excel: How to implement batch export of data In many front-end developments, exporting data to Excel is a common requirement. As a popular JavaScript framework, Vue provides many convenient tools and methods to achieve this function. This article will introduce how to use Vue and Excel.js libraries to implement the batch export function of data. First, we need to install the Excel.js library. It can be installed using the npm package manager: npminstall

Golang Practical Combat: Sharing of Implementation Tips for Data Export Function Golang Practical Combat: Sharing of Implementation Tips for Data Export Function Feb 29, 2024 am 09:00 AM

The data export function is a very common requirement in actual development, especially in scenarios such as back-end management systems or data report export. This article will take the Golang language as an example to share the implementation skills of the data export function and give specific code examples. 1. Environment preparation Before starting, make sure you have installed the Golang environment and are familiar with the basic syntax and operations of Golang. In addition, in order to implement the data export function, you may need to use a third-party library, such as github.com/360EntSec

Detailed explanation of using Golang to implement data export function Detailed explanation of using Golang to implement data export function Feb 28, 2024 pm 01:42 PM

Title: Detailed explanation of data export function using Golang. With the improvement of informatization, many enterprises and organizations need to export data stored in databases into different formats for data analysis, report generation and other purposes. This article will introduce how to use the Golang programming language to implement the data export function, including detailed steps to connect to the database, query data, and export data to files, and provide specific code examples. To connect to the database first, we need to use the database driver provided in Golang, such as da

See all articles