Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use mysqldump only to back up the table structure

Shulou Source: shulou.com Published: 2022-05-31 21:02:17 09月19日 Update

This article introduces you how to use mysqldump only backup table structure, the content is very detailed, interested friends can refer to, I hope to help you.

Use the--no-data option, for example:

C:\Users\duansf\Desktop>mysqldump -uroot -p123456 --no-data --databases test > test.sql

test.sql reads as follows:

-- MySQL dump 10.13 Distrib 5.5.13, for Win32 (x86)

--

-- Host: localhost Database: test

-- ------------------------------------------------------

-- Server version 5.5.13

/*! 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 */;

--

-- Current Database: `test`

--

CREATE DATABASE /*! 32312 IF NOT EXISTS*/ `test` /*! 40100 DEFAULT CHARACTER SET gbk */;

USE `test`;

--

-- Table structure for table `workinfo`

--

DROP TABLE IF EXISTS `workinfo`;

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

/*! 40101 SET character_set_client = utf8 */;

CREATE TABLE `workinfo` (

`id` int(10) NOT NULL AUTO_INCREMENT,

`name` varchar(20) NOT NULL,

`type` varchar(10) DEFAULT NULL,

`address` varchar(50) DEFAULT NULL,

`tel` varchar(20) DEFAULT NULL,

`wages` int(11) DEFAULT NULL,

`contents` tinytext,

`extra` text,

PRIMARY KEY (`id`),

UNIQUE KEY `id` (`id`),

UNIQUE KEY `index_id` (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

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

/*! 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 2016-08-11 14:56:15

About how to use mysqldump only backup table structure to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Content backup structure more help good interest guys buddies articles knowledge articles references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology MySQL Apple macOS