首先,打开MysqlWorkbench
点击LocalinstanceMySql57进行登录,输入root密码
登录进去后,点击左边栏的administrationt选项卡
在里面找到“dataimport/restore”,点击进入。
这个地方需要选择importfromself-containedfile,从文件夹中选择备份的文件,然后在defaulttargetschema选项里选择要还原的数据库名称。右下角选择“dumpstructureanddata”
一切准备就绪后,点击右下角的“startimport”,开始还原数据库,最后进度条完成后,表示数据库还原完成。
mysql>CREATE DATABASE sakila
mysql>USE sakila
mysql>CREATE TABLE actor (
actor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (actor_id),
KEY idx_actor_last_name (last_name)
)ENGINE=InnoDB DEFAULT CHARSET=utf8
ALTER TABLE {库名}.{表名} DISCARD TABLESPACE
例:
mysql>ALTER TABLE sakila.actor DISCARD TABLESPACE
cp /backup_directory/actor.ibd path/to/mysql-5.7/data/sakila/
ALTER TABLE {库名}.{表名} IMPORT TABLESPACESHOW WARNINGS
例:
mysql>ALTER TABLE sakila.actor IMPORT TABLESPACESHOW WARNINGS
Query OK, 0 rows affected, 1 warning (0.15 sec)
Warning | 1810 | InnoDB: IO Read error: (2, No such file or directory)
Error opening './sakila/actor.cfg', will attempt to import
without schema verification
mysql>SELECT COUNT(*) FROM sakila.actor
+----------+
| count(*) |
+----------+
| 200 |
+----------+
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)