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

Common sentences in Mysqldump

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

Share

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

1: export a table structure and data of the database

. / mysqldump-- opt-h 192.168.1.123-u root-p dbname table1 > / Users/1.sql

The-- opt here comes with various options-the address of the server followed by mysql can be omitted locally-u followed by the user name dbname is the database name table1 is the table name > followed by the path to the local hard disk and the file name to be generated

2: export the entire database, that is, the table name is not written after the above database.

. / mysqldump-- opt-h 192.168.1.123-u root-p dbname > / Users/1.sql

3: the structure of a table in the export database does not include data

. / mysqldump-- opt-d-h 192.168.1.123-u root-p dbname table1 > / Users/1.sql

Just export the structure here, and just add one more-d to the first one.

4: export the structure of the entire database

. / mysqldump-- opt-d-h 192.168.1.123-u root-p dbname > / Users/1.sql

Here, just add a-d to the data in the second item.

5: export some data in the database table, that is, filter the data with conditions

. / mysqldump-- opt-h 192.168.1.123-u root-p dbname table1-- where= "field 1 includes' and field 2 minutes' and field 3 minutes' order by field 4 desc limit 0shot 30" > / Users/1.sql

The option-where is added here, where the where condition is the same as sql, except that the entire where condition is enclosed in double quotes. This statement only fetches the first 30 pieces of data that satisfy the condition, and the structure of the table is included here.

6: export some data from a table in the database without the structure of the table

. / mysqldump-- opt-d-h 192.168.1.123-u root-p dbname table1-- where= "field 1 includes' and field 2 percent 'and field 3 minutes' order by field 4 desc limit 0focus 30" > / Users/1.sql

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