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

What are the mysql import and export commands

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

Share

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

What are the mysql import and export commands, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, hope you can gain something.

Use mysqldump and source

You can export data in this way:

Mysqldump-urott-P5678-- default-character-set=gb2312-p-h227.0.0.1 Test test1 > test1.sql

You can also do this:

Mysql-uroot-P5678-- default-character-set=gb2312-p-h227.0.0.1-e "select * from Test.test1" > test1.sql (although you need to create the table manually, of course you can get the table statement by show create test1)

Import:

You can do this (under the mysql command line)

Mysql > use Test

Mysql > source test1.sql

If you get the file in select, you should import it like this:

Mysql > load data infile "test.sql" into table Test.test1

When importing, you can "show processlistG" to view the import status.

Sometimes errors occur: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`Test/ test1`, CONSTRAINT `xxx` FOREIGN KEY (`AA`) REFERENCES `BB` (`AA`))

At this point, you need to delete foreign key constraints, such as:

Alter table cwealinfo drop foreign key `xxx`

Also available: set foreign_key_checks = 0

If you need to pay attention to the version you need to pay attention to when exporting and importing, such as importing from 4 to 5, it is best to use 4 dump, otherwise you may fail. Also need to pay attention to character set problems, if the character sets of the two libraries are different, it may cause problems, so it is best to use "show variables like% char%" before import to see if the character set settings need to be adjusted.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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