Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command mysqldump

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of the Linux basic command mysqldump". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command mysqldump".

Mysqldump

Mysqldump is a client backup program that can back up the database or transfer the database to another server.

The scope of application of this command: RedHat, RHEL, Ubuntu, CentOS, Fedora.

1. Grammar

Mysqldump [options] [db_name [tbl_name...]]

2. List of option parameters

Option

Description

-? |-- help

Display help information

-- add-drop-database

Add delete database statements before creating the database

-- add-drop-table

Add delete table statements before creating the table

-- add-locks

Add a lock table statement when outputting insert statements

-A |-- all-database

Back up all tables in all databases

-- allow-keywords

Allow column names to use keywords

-- bind-address=ip

Bind ip

-- character-set-dir

Default character set directory

-I |-- comments

Add comments during backup

-c |-- complete-insert

Use the complete insert statement

-C |-- compress

Use compressed statements between the server and the client

-B |-- database

Specify the database to back up

-- dump-date

If you use the-comments option, you can append a date

-F |-- flush-logs

Refresh the log

-- flush-privileges

Refresh permissions

-f |-- force

Enforcement

-ignore-table

Ignore tables when backing up

-- lock-all-tables |-x

Lock all databases during backup

-l |-- lock-tables

Lock the specified table

-- log-error

Error log

-t |-- no-create-db

Create table statements are not output when backing up the database

-d |-- no-data

When backing up the database, only the data structure is backed up, not the data

-P |-- port

Designated port

-- protocol

Specified protocol

-Q |-- quick

Silent mode

-v |-- verbose

Show detailed procedures

-V |-- version

Display version information

-u |-- user

Designated user

-p |-- password

Specify password

3. Examples

Back up the specified table in the specified database

[root@localhost ~] # mysqldump-v-u root-p wordpress wp_links / / by default, backup content to standard output

Enter password:

-- Connecting to localhost...

-- MySQL dump 10.13 Distrib 5.1.71, for redhat-linux-gnu (i386)

--

-- Host: localhost Database: wordpress

-

-- Server version 5.1.71

/ * 40101 SET @ OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT * /

/ * 40101 SET @ OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS * /

/ * 40101 SET @ OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION * /

/ * 40101 SET NAMES utf8 * /

/ * 40103 SET @ OLD_TIME_ZONE=@@TIME_ZONE * /

/ * 40103 SET TIME_ZONE='+00:00' * /

/ * 40014 SET @ OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 * /

/ * 40014 SET @ OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 * /

/ * 40101 SET @ OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' * /

/ * 40111 SET @ OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 * /

-- Retrieving table structure for table wp_links...

--

-- Table structure for table `wp_ links`

--

DROP TABLE IF EXISTS `wp_ links`

/ *! 40101 SET @ saved_cs_client = @ @ character_set_client * /

/ *! 40101 SET character_set_client = utf8 * /

CREATE TABLE `wp_ links` (

`link_ id` bigint (20) unsigned NOT NULL AUTO_INCREMENT

`link_ url`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ name`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ image`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ target`varchar (25) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ substitution`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ visible` varchar (20) COLLATE utf8_unicode_ci NOT NULL DEFAULT'Y'

`link_ owner`bigint (20) unsigned NOT NULL DEFAULT'1'

`link_ rating` int (11) NOT NULL DEFAULT'0'

`link_ updated`datetime NOT NULL DEFAULT '0000-00-0000: 0000'

`link_ rel`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ notes` mediumtext COLLATE utf8_unicode_ci NOT NULL

`link_ rss`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

PRIMARY KEY (`link_ id`)

KEY `link_ visible` (`link_ visible`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

/ * 40101 SET character_set_client = @ saved_cs_client * /

-- Sending SELECT query...

--

-- Dumping data for table `wp_ links`

--

-- Retrieving rows...

LOCK TABLES `wp_ links` WRITE

/ *! 40000 ALTER TABLE `wp_ Links` DISABLE KEYS * /

/ *! 40000 ALTER TABLE `wp_ Links` ENABLE KEYS * /

UNLOCK TABLES

-- Disconnecting from localhost...

/ * 40103 SET TIME_ZONE=@OLD_TIME_ZONE * /

/ * 40101 SET SQL_MODE=@OLD_SQL_MODE * /

/ * 40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS * /

/ * 40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS * /

/ * 40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT * /

/ * 40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS * /

/ * 40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION * /

/ * 40111 SET SQL_NOTES=@OLD_SQL_NOTES * /

-- Dump completed on 2018-10-05 20:34:17

You have new mail in / var/spool/mail/root

2) View active threads

[root@localhost ~] # mysqldump-v-u root-p wordpress wp_links > sql.bak / / back up to sql.bak using the redirect feature

Enter password:

-- Connecting to localhost...

-- Retrieving table structure for table wp_links...

-- Sending SELECT query...

-- Retrieving rows...

-- Disconnecting from localhost...

You have new mail in / var/spool/mail/root

[root@localhost ~] # cat sql.bak / / View backup content

-- MySQL dump 10.13 Distrib 5.1.71, for redhat-linux-gnu (i386)

--

-- Host: localhost Database: wordpress

-

-- Server version 5.1.71

/ * 40101 SET @ OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT * /

/ * 40101 SET @ OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS * /

/ * 40101 SET @ OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION * /

/ * 40101 SET NAMES utf8 * /

/ * 40103 SET @ OLD_TIME_ZONE=@@TIME_ZONE * /

/ * 40103 SET TIME_ZONE='+00:00' * /

/ * 40014 SET @ OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 * /

/ * 40014 SET @ OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 * /

/ * 40101 SET @ OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' * /

/ * 40111 SET @ OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 * /

--

-- Table structure for table `wp_ links`

--

DROP TABLE IF EXISTS `wp_ links`

/ *! 40101 SET @ saved_cs_client = @ @ character_set_client * /

/ *! 40101 SET character_set_client = utf8 * /

CREATE TABLE `wp_ links` (

`link_ id` bigint (20) unsigned NOT NULL AUTO_INCREMENT

`link_ url`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ name`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ image`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ target`varchar (25) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ substitution`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ visible` varchar (20) COLLATE utf8_unicode_ci NOT NULL DEFAULT'Y'

`link_ owner`bigint (20) unsigned NOT NULL DEFAULT'1'

`link_ rating` int (11) NOT NULL DEFAULT'0'

`link_ updated`datetime NOT NULL DEFAULT '0000-00-0000: 0000'

`link_ rel`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

`link_ notes` mediumtext COLLATE utf8_unicode_ci NOT NULL

`link_ rss`varchar (255) COLLATE utf8_unicode_ci NOT NULL DEFAULT''

PRIMARY KEY (`link_ id`)

KEY `link_ visible` (`link_ visible`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

/ * 40101 SET character_set_client = @ saved_cs_client * /

--

-- Dumping data for table `wp_ links`

--

LOCK TABLES `wp_ links` WRITE

/ *! 40000 ALTER TABLE `wp_ Links` DISABLE KEYS * /

/ *! 40000 ALTER TABLE `wp_ Links` ENABLE KEYS * /

UNLOCK TABLES

/ * 40103 SET TIME_ZONE=@OLD_TIME_ZONE * /

/ * 40101 SET SQL_MODE=@OLD_SQL_MODE * /

/ * 40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS * /

/ * 40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS * /

/ * 40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT * /

/ * 40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS * /

/ * 40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION * /

/ * 40111 SET SQL_NOTES=@OLD_SQL_NOTES * /

-- Dump completed on 2018-10-05 20:36:27

Thank you for your reading, the above is the content of "the usage of the Linux basic command mysqldump". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command mysqldump, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report