怎样从frm ibd恢复mysql_怎样从frm,ibd恢复MYSQL

2015-07-01 回答

method #1 – create work tables

1. start up clean/fresh instance of mysql with innodb_file_per_table enabled.

2. now, we need to find the table id that mysql is currently set at, as well as the table id for the table we need to recover.

note:

step 2 (2a – 2f) is simply to find the table id that is stored inside of

the .ibd file. i’ve written a php script to determine this, so using

the script can save a bunch of time. see the bottom of this page (under

“associated files”) for the exact script.

2a. create a test database:

mysql> create database test1;

mysql> use test1;

2b. issue the create table command for the table:

mysql> create table `product` (

`product_id` bigint(20) unsigned not null auto_increment,

`brand_id` int(10) unsigned default null,

`product_type_id` int(10) unsigned default null,

`group_id` int(10) unsigned default null,

`product_name` varchar(500) not null,

`default_email_id` varchar(48) default null,

`product_status` tinyint(1) not null,

`client_id` bigint(20) unsigned default null,

`last_modified_by` varchar(45) not null,

`last_modified_date` datetime not null,

primary key (`product_id`)

) engine=innodb;

2c. discard the tablespace, which will delete the newly created .ibd file:

mysql> alter table product discard tablespace;

2d. copy the pre-existing .ibd file to the datadir/test1 folder

2e. import this tablespace:

mysql> alter table product import tablespace;

this should produce the following error (at least this is most likely).

the only way it would not is if mysql’s current table id matched that of

the preexisting ibd table id. in which case, you can now dump your

table.

error 1030 (hy000): got error -1 from storage engine

2f. so, now to check the error log (manually). look for the following entry:

081010 11:47:40 innodb: error: tablespace id in file

'.test1product.ibd' is 1193, but in the innodb

innodb: data dictionary it is 1.

so, now we know the internal table id is at 1, and that of the ibd table is 1193.

3. clean up working database:

3a. manually move the ibd file from the $datadir to a safe location (as you will need this file again).

3b. drop this table.

mysql> drop table product;

note this does not re-set the internal table counter.

4. you’ll need to create the number of tables you need to increase the internal table id value.

in this case, you’d create 1191 test innodb tables (already at 1, and

need to leave 1 for the actual table, so 1193-2=1191). run below in a

loop.

for ($1=1; $i<=1191; $1++) {

create table t# (id int) engine=innodb;

}

i accomplished this via a simple php script. see the bottom of this page (under "associated files") for the exact script.

5. after these are created, go ahead and drop this database and all tables (as they are not needed).

drop db test1;

6. now, re-perform steps 2a through 2e.

mysql> create database test1;

mysql> use test1;

mysql> create table `product` ( ... ) engine=innodb;

mysql> alter table product discard tablespace;

mysql> alter table product import tablespace;

success!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/354240.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

extjs6 mvvm_ZK 6中的MVVM初探

extjs6 mvvmMVVM与MVC 在上一篇文章中&#xff0c;我们已经看到Ajax框架ZK如何采用CSS选择器启发的Controller来在View中连接UI组件并监听它们的事件。 在此ZK MVC模式下&#xff0c; View中的UI组件无需绑定到任何Controller方法或数据对象。 使用选择器模式作为将View状态和事…

多线程 调用 axis 报错_java笔记录(三、多线程)

1、进程和线程&#xff1a;进程&#xff1a;正在进行的程序。每一个进程执行都有一个执行顺序&#xff0c;该顺序是一个执行路径&#xff0c;或者叫一个控制单元。线程&#xff1a;进程内部的一条执行路径或者一个控制单元。两者的区别&#xff1a;一个进程至少有一个线程进程在…

使用PropertyPlaceholderConfigurer读取属性文件

1.简介 通常&#xff0c;当我们考虑将多个应用程序部署到生产环境之前在其中部署服务器时&#xff0c;可以在外部属性文件中配置特定于环境的参数 。 它可能是数据库详细信息&#xff0c;对于测试服务器和生产服务器而言&#xff0c;这是不同的。 因此最好选择将数据库配置文件…

第二天:Swift手势操控弹性按钮

参考链接:https://www.jianshu.com/p/f080ede0f3a8 1 import UIKit2 3 fileprivate let buttonH: CGFloat 2004 5 class ViewController: UIViewController, UIGestureRecognizerDelegate {6 7 IBOutlet weak var segmentControl: UISegmentedControl!8 var randomBtn…

asp获取mysql数据报错_ASP.NET在删除掉数据库文件后报错处理

在开发asp.net mvc程序时&#xff0c;默认时我们会使用LocalDB, 我们有时会以为删除掉App_Data目录就可以自动新建数据库&#xff0c;但是我们在网站重新启动后(进入Account)就会发现报如下错误&#xff1a;The ASP.NET Simple Membership database could not be initialized. …

按插入顺序排序的map

LinkedHashMap HashMap是无序的&#xff0c;HashMap在put的时候是根据key的hashcode进行hash然后放入对应的地方。所以在按照一定顺序put进HashMap中&#xff0c;然后遍历出HashMap的顺序跟put的顺序不同。单纯的HashMap是无法实现排序的。 区别&#xff1a; 1.HashMap里面存入…

lua excel to mysql_在Lua程序中使用MySQL的教程

http://www.jb51.net/article/66972.htmhttps://www.2cto.com/database/201501/372767.html常用sql语句&#xff1a;mysql -h localhost -u 用戶名 -p密碼 //連接數據庫use desk_show; //使用數據庫show tables; …

java实践_Java怪异实践

java实践总览 Java中有许多实践使我感到困惑。 这里只是一些。 使用-Xmx和-Xms 选项-Xmx广泛用于设置最大内存大小。 如Java HotSpot VM Options中所述&#xff0c;以-X开头的选项是非标准的&#xff08;不保证所有VM实施都支持该选项&#xff09;&#xff0c;并且在以后的JDK…

函数参数:

函数参数&#xff1a;一、位置参数:按顺序一一对应赋值 def stu(name,age,course,country) stu("刘老根",25,"linux","CN")二、关健参数&#xff1a;在实参中使用 号赋值&#xff08;可以不按顺序&#xff09; def stu(name,a…

mysql group by 重复_mysql – 使用GROUP BY删除重复项的查询

id_specific_price id_product-------------------------------1 22 23 24 35 36 37 3需要删除重复项,预期结果&#xff1a;id_specific_price id_product-------------------------------3 27 3SELECT *FROM ps_specific_priceWHERE id_specific_price NOT IN(SELECT MAX(id_s…

您的JAX-RS API并非天生就等于:使用动态功能

这次&#xff0c;我们将讨论一些有关JAX-RS 2.0 API的内容&#xff0c;并涉及该规范的一个非常有趣的方面&#xff1a; 动态功能以及它们的有用性。 传统上&#xff0c;当配置和部署JAX-RS 2.0 API&#xff08;使用Application类&#xff0c;从servlet引导或通过RuntimeDelega…

ionic2 安装与cordova打包

1.安装&#xff1a; cnpm install -g cordova ionic ionic start name cd name cnpm install 2、环境配置&#xff1a; http://www.cnblogs.com/changyaoself/p/6544082.html 这里是具体配置。 测试环境&#xff1a; cordova platform list 如下才可以&#xff1a; 3、添加…

mysql vacuum_PostgreSQL DBA快速入门(四) - 体系架构

PostgreSQL在开源关系型数据库市场是最先进的数据库。他的第一个版本在1989年发布&#xff0c;从那时开始&#xff0c;他得到了很多扩展。根据db-enginers上的排名情况&#xff0c;PostgreSQL目前在数据库领域排名第四。 本篇博客&#xff0c;我们来讨论一下PostgreSQL的内部架…

(ab)使用Java 8 FunctionalInterfaces作为本地方法

如果您使用Scala或Ceylon甚至JavaScript等更高级的语言进行编程&#xff0c;则“嵌套函数”或“本地函数”是您非常常见的习惯用法。 例如&#xff0c;您将编写诸如fibonacci函数之类的东西&#xff1a; def f() {def g() "a string!"g() "– says g" …

mysql的配置实现远程访问_MySQL 远程连接配置的正确实现 | 学步园

此文章主要向大家描述的是MySQL远程连接配置的实际操作步骤&#xff0c;以及在其实际操作中值得我们大家注意的相关事项的描述&#xff0c; 以下就是具体方案的描述&#xff0c;希望在你今后的学习中会有所帮助。MySQL远程配置GRANT ALL PRIVILEGES ON *.* TO root% IDENTIFIED…

oracle 用户账户被锁处理

一、以管理员身份登录 SQL> conn sys/sys as sysdba; &#xff08;分号是必须的但是我是以system登录的所在这不应该写conn sys/sys as sysdba应该写conn system/orcl as sysdba;&#xff09;Connected. 二、解锁被锁用户SQL> alter user scott account unlock;User alte…

总结mysql的基础语法_mysql 基础sql语法总结 (二)DML

二、DML(增、删、改)1)插入数据第一种写法&#xff1a;INSERT INTO 表名 (列名1&#xff0c;列名2&#xff0c;&#xff0c;......)VALUES(列值1&#xff0c;列值2&#xff0c;......)第二种写法&#xff1a;INSERT INTO 表名 VALUES(列值1&#xff0c;列值2&#xff0c;......…

提高团队协作效率

提高团队协作效率 分工合理&#xff0c;责任明确 团队是由个人组成的&#xff0c;团队中的个人往往经历不同、背景不同、性格有差异、水平有高低。在团队形成后、正式开工前&#xff0c;首先应该进行合理分工&#xff0c;要结合每个 人的特点和爱好&#xff0c;充分发挥出每个人…

mysql远程访问时间长无反应_远程MySQL访问需要很长时间

Running a MySQL query on a local database takes only about 20-30ms but running the same query through a remote connection(internet) takes 500ms. Is this normal? If not what could be the possible reason for such delay?This is a wireshark time extract for …

c# 利用AForge和百度AI开发实时人脸识别

baiduAIFaceIdentify项目是C#语言&#xff0c;集成百度AI的SDK利用AForge开发的实时人脸识别的小demo&#xff0c;里边包含了人脸检测识别&#xff0c;人脸注册&#xff0c;人脸登录等功能 人脸实时检测识别功能 思路是利用AForge打开摄像头&#xff0c;通过摄像头获取到的图像…