maria-discuss team mailing list archive
-
maria-discuss team
-
Mailing list archive
-
Message #04443
Re: restore db from dump?
That's the work around though.
But what OP asks is also a valid scenario in real life scenario. If we have
such options like selective load, remapping databases then its really a
wonderful.
On Thu, Apr 6, 2017 at 12:27 AM, Reindl Harald <h.reindl@xxxxxxxxxxxxx>
wrote:
>
>
> Am 05.04.2017 um 20:43 schrieb l vic:
>
>> 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?
>>
>
> when you say "--all-databases", well, than all databases and their
> drop/create statements are included because you said to do so
>
> if you want a specific database, well, the specify it or at least manually
> edit the dump before restore and remove anything you don't ant
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~maria-discuss
> Post to : maria-discuss@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~maria-discuss
> More help : https://help.launchpad.net/ListHelp
>
Follow ups
References