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

Mysql basic Import and Export data Command

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

Share

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

This article mainly explains the "mysql basic import and export data commands", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn the "mysql basic import and export data commands" bar!

1. Export the entire

Dump-u user name-p database name > exported file name

Mysqldump-u wcnc-p smgp_apps_wcnc > wcnc.sql

two。 Export a table

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

Mysqldump-u wcnc-p smgp_apps_wcnc users > wcnc_users.sql

3. Export a database structure

Mysqldump-u wcnc-p-d-- add-drop-table smgp_apps_wcnc > d:\ wcnc_db.sql

-d No data-- add-drop-table adds a drop table before each create statement

4. 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

Add:

Mysqldump supports the following options:

-- add-locks

Add LOCK TABLES before each table is exported and then UNLOCK TABLE. (for faster insertion into the MySQL).

-- add-drop-table

Add a drop table before each create statement.

-- allow-keywords

Allows you to create column names that are keywords. This is done by adding the table name before the column name.

-c,-- complete-insert

Use the full insert statement (with column names).

-C,-- compress

If both the client and the server support compression, compress all the information between them.

-- delayed

Insert a row with the INSERT DELAYED command.

-e-- extended-insert

Use the new multiline INSERT syntax. (give more compact and faster insert statements)

-#,-- debug [= option_string]

Track the use of the program (for debugging).

-- help

Displays a help message and exits.

-- fields-terminated-by=...

-- fields-enclosed-by=...

-- fields-optionally-enclosed-by=...

-- fields-escaped-by=...

-- fields-terminated-by=...

These choices are used with the-T selection and have the same meaning as the corresponding LOAD DATA INFILE clause.

LOAD DATA INFILE syntax.

-F,-- flush-logs

Before you start exporting, wash out the

Journal

Files.

-f,-- force

Even if we get a SQL error during a table export, continue.

-h,-- host=..

Export data from a MySQL server on a named host. The default host is localhost.

-l,-- lock-tables.

Lock all tables to start the export.

-t,-- no-create-info

Do not write table creation information (CREATE TABLE statement)

-d,-- no-data

No row information is written to the table. This is useful if you only want to get an export of the structure of a table!

-- opt

Same as-- quick-- add-drop-table-- add-locks-- extended-insert-- lock-tables.

Should give you the fastest possible export for reading into a MySQL server.

-pyour_pass,-- password [= your_pass]

The password used to connect to the server. If you do not specify the "= your_pass" section, mysqldump requires a password from the terminal.

-P port_num,-- port=port_num

The TCP/IP port number used when connecting to a host. (this is used to connect to a host other than localhost because it uses Unix sockets. )

-Q,-- quick

Without buffering the query, export it directly to stdout; and use mysql_use_result () to do it.

S / path/to/socket,-- socket=/path/to/socket

The socket file used when connecting to localhost, which is the default host.

-T,-- tab=path-to-some-directory

For each given table, create a table_name.sql file that contains SQL CREATE commands, and a table_name.txt file that contains data. Note: this is only if mysqldump is running on the same machine as the mysqld daemon

Work

. The format of the .txt file is based on the-- fields-xxx and-- lines--xxx options.

-u user_name-- user=user_name

The user name used by MySQL when connecting to the server. The default is your Unix login.

-O var=option,-- set-variable var=option

Sets the value of a variable. Possible variables are listed below.

-v,-- verbose

Lengthy mode. Print out more information about what the program does.

-V-- version

Print version information and exit.

-W,-- where='where-condition'

Export only selected records; note that quotation marks are mandatory!

"--where=user='jimf'"- wuserid > 1"- wuserid

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