Home > Database > Mysql Tutorial > body text

How to export only the table structure in mysql

WBOY
Release: 2022-05-19 10:59:35
Original
7294 people have browsed it

Method: 1. Use the "mysqldump --opt -d database name -u root -p >..." statement to export the structure of the database table; 2. Use "mysqldump -uroot -p -B database Name --table table name>..." statement exports the structure of the specified table.

How to export only the table structure in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How does mysql export only the table structure

mysql mysqldump only exports the table structure but not the data

1. Export the structure but not the data

The code is as follows:

mysqldump --opt -d 数据库名 -u root -p > xxx.sql
Copy after login

2. Export data without exporting the structure

The code is as follows:

mysqldump -t 数据库名 -uroot -p > xxx.sql
Copy after login

3. Export data and tables Structure

The code is as follows:

mysqldump 数据库名 -uroot -p > xxx.sql
Copy after login

4. Export the structure of a specific table

The code is as follows:

mysqldump -uroot -p -B 数据库名 --table 表名 > xxx.sql
Copy after login

Extension Knowledge:

mysqldump is MySQL’s own logical backup tool.

Its backup principle is to connect to the MySQL database through the protocol, query the data that needs to be backed up, and convert the queried data into corresponding insert statements. When we need to restore the data, we only need to execute these inserts statement to restore the corresponding data.

Backup command

Command format

mysqldump [选项] 数据库名 [表名] > 脚本名
Copy after login

or

mysqldump [选项] --数据库名 [选项 表名] > 脚本名
Copy after login

or

mysqldump [选项] --all-databases [选项] > 脚本名
Copy after login

Recommended learning: mysql video tutorial

The above is the detailed content of How to export only the table structure in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!