Hello,
I have "mydump.sql" with dump of all databases in cluster. I am trying
to selectively restore one database only from the scenario below:
Have created 2 databases: test1 and test2 with table "person":
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| name | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
Insert name "one" into table "person" for both databases:
insert into person values ('name');
Backup all data into "mysqldump.sql":
mysqldump -P3306 -uroot -pdbpass --all-databases >mysqldump.sql
drop database test2 (my mistake);
and insert additional data into "test1":
insert into person values ('name1');
insert into person values ('name2');
Now, i'd like to restore database test2 only:
mysql -uroot -pdbpass -e "create database if not exists test2;"
mysql -uroot -pdbpass test2 < mysqldump.sql
Success !! test2 is restored with all the data, but when I'checked
"test1" i only see one record "name" - two records that I've added after
backup are lost
It looks as mysql just restore all data in dump file, regardless of
specifying the "target" database.
Is that expected, or do i have some error in my backup/restore procedure?
If this is expected, is there some comprehensive method to restore one
database selectively?