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 ~