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

How to use commands to export / import table structure and data from mysql

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to use commands to export / import table structures and data from mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Under the command line, there is a good command mysqldump for mysql data export, which has a large number of parameters, which can be viewed as follows:

Mysqldump

The most commonly used:

Mysqldump-uroot-pmysql databasefoo table1 table2 > foo.sql

In this way, the table table1 and table2 of databasefoo can be imported into foo.sql in the form of sql, where the-uroot parameter indicates that the user name for accessing the database is root. If you have a password, you need to add the-p parameter.

Eg:

C:\ Users\ jack > dump-uroot-pmysql sva_rec date_drv > e:\ date_drv.sql

Mysql data import is also quite convenient, such as:

Mysql-uroot databasefoo

< foo.sql 这样就可以将foo.sql的数据全部导入数据库databasefoo 1.导出整个数据库   mysqldump -u用户名 -p密码 数据库名 >

Exported file name

C:\ Users\ jack > mysqldump-uroot-pmysql sva_rec > e:\ sva_rec.sql

two。 Export a table, including table structure and data

Mysqldump-u user name-p password database name table name > exported file name

C:\ Users\ jack > mysqldump-uroot-pmysql sva_rec date_rec_drv > e:\ date_rec_drv.sql

3. Export a database structure

C:\ Users\ jack > mysqldump-uroot-pmysql-d sva_rec > e:\ sva_rec.sql

4. Export a table with only table structure

Mysqldump-u user name-p password-d database name table name > exported file name

C:\ Users\ jack > mysqldump-uroot-pmysql-d sva_rec date_rec_drv > e:\ date_rec_drv.sql

5. Import database

Common source commands

Enter the my console

Such as mysql-u root-p

Mysql > use database

Then use the source command, followed by a script file (such as .sql used here)

Mysql > source d:wcnc_db.sql

Sometimes, to import data into the import mysql, you can write an importer or a java script to implement it.

Thank you for reading! On "how to use commands to export / import table structure and data from mysql" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

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

Database

Wechat

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

12
Report