Note Mysqldump a small problem with exporting an import database ~

Source: Internet
Author: User
Tags import database

Received the request of the leadership, asked to create a new library on the test server, the data is identical to the original test library, for testing purposes, so I

Mysqldump-uroot-ppassword--databases dbname > Newdb.sql

After exporting the original library, I tail the newdb.sql, well, there is content.

Then create databases newdb, switch to newdb

Source/root/newdb.sql

Because the data is relatively large ~ time-consuming relatively long. About 2 hours ...

After 2 hours of data was finished, I switched to newdb,show tables and found ... Unexpectedly no data!!!

I was wondering if someone had interrupted the mission after MySQL ...

Asked the other colleagues no one connected ah, depressed, so I repeat the above steps ...

Two hours after viewing, or not!!! Calm down after a burst of madness ...

Head-50 Newdb.sql

I found that the exported script was preceded by a

Create dbname

Then the

Use dbname

That is, I just did the import operation is in the original library above the ... White play a Day ~

OK, find the problem to solve the problem, the two statements in the dbname changed to newdb on the line, wit like me Ah

So I'm habitual.

Vim Newdb.sql

The question comes, more than 10 g of the script file, I actually want to use VIM to modify ... The pattern Tucson broken ...

Before learning to remember when the export can not generate these two statements? So I checked the parameters of mysqldump, really ~

Mysqldump-uroot-ppassword--no-create-db--databases dbname > Newdb.sql

Export only data without adding the Create databases statement.

Then head looks at the script, uh, without the Create DBNAME statement.

But... Still have use dbname!!! This will still be imported into the original library Ah Ah Ah

No way, or change the Newdb.sql script to start it.

Abandon the idea of vim, ask for children's shoes, use sed or awk to achieve

So I Baidu a bit, with the following command to modify:

Sed-i ' 1,40s/dbname/newdb/g '

Wait a while, the operation is complete, head view, has been changed

Then repeat the import operation, hours later~

The whole world, pure ...

Ah ~ because of their ignorance results have been so long

Must study hard in the future, hair dung painted wall ~

Note Mysqldump a small problem with exporting an import database ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.