简体   繁体   English

从备份中恢复 MySQL 表

[英]Restore MySQL table from backup

I have created backup of a specific table from my database by using the command below.我使用以下命令从我的数据库创建了特定表的备份。

mysqldump -u root -p db_name table_name > table.sql

Is it possible to restore the specific backup table without affecting the data of the rest of the tables?是否可以在不影响其余表数据的情况下恢复特定备份表? Which means, whatever data from my backup file for my table will be the only one affected?这意味着,我的表的备份文件中的任何数据都将是唯一受影响的数据?

The reverse will be:反过来将是:

mysql database_name < database_name.sql

But this is for the whole database.但这是针对整个数据库的。 How to do it with table backup alone?单靠表备份怎么做?

While the answer given by "Pradeep Reddy" is absolutely correct there is another way of doing it as well from inside mysql prompt using the SOURCE command.虽然“Pradeep Reddy”给出的答案是绝对正确的,但还有另一种方法可以使用SOURCE命令从 mysql 提示符内部执行此操作。

mysql> USE database_name;

mysql> SOURCE /my_fullpath_to_backup_folder/table.sql

mysql -u root -p数据库名<mytable.sql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM