我正在一个项目中,我只有一个数据mysqldump(可能是用--no-create-info创建的),所以转储中的所有表创建命令都丢失了,并且有关列的信息也丢失了。以前的开发人员既未提供完整的转储,也未提供数据库。我想还原仅由数值和时间戳组成的数据库。是否有工具可以尽可能地恢复表及其结构?
编辑: 恢复的目的是能够利用python库读取数据并进一步处理它们(而不是使结果数据库在后端可操作)。因此,能够使用某些sql库将部分还原的数据库中的数据转换为pandas数据框会很好。我当然可以编写一些带有正则表达式的python脚本,以直接从转储中提取数据。但是我想知道是否已经存在一些更优雅的方法来实现部分恢复。
转储的截短示例为:
-- MySQL dump 10.16 Distrib 10.1.23-MariaDB, for debian-linux-gnueabihf (armv7l)
--
-- Host: localhost Database: sensordata
-- ------------------------------------------------------
-- Server version 10.1.23-MariaDB-9+deb9u1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Dumping data for table `humidity`
--
LOCK TABLES `humidity` WRITE;
/*!40000 ALTER TABLE `humidity` DISABLE KEYS */;
INSERT INTO `humidity` VALUES (1,25,58),(2,24,58),(3,24,58);
/*!40000 ALTER TABLE `humidity` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `humidity22`
--
LOCK TABLES `humidity22` WRITE;
/*!40000 ALTER TABLE `humidity22` DISABLE KEYS */;
INSERT INTO `humidity22` VALUES (1,25.1,53.4),(2,24.8,53.1),(3,24.8,53.1);
/*!40000 ALTER TABLE `humidity22` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `moisture1`
--
LOCK TABLES `moisture1` WRITE;
/*!40000 ALTER TABLE `moisture1` DISABLE KEYS */;
INSERT INTO `moisture1` VALUES (1,0),(2,0),(3,0);
/*!40000 ALTER TABLE `moisture1` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `moisture2`
--
LOCK TABLES `moisture2` WRITE;
/*!40000 ALTER TABLE `moisture2` DISABLE KEYS */;
INSERT INTO `moisture2` VALUES (1,0),(2,0),(3,0);
/*!40000 ALTER TABLE `moisture2` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `pressure`
--
LOCK TABLES `pressure` WRITE;
/*!40000 ALTER TABLE `pressure` DISABLE KEYS */;
INSERT INTO `pressure` VALUES (1,24.7,97326,337.362),(2,24.6,97321,338.136),(3,24.6,97333,337.62);
/*!40000 ALTER TABLE `pressure` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `rain`
--
LOCK TABLES `rain` WRITE;
/*!40000 ALTER TABLE `rain` DISABLE KEYS */;
INSERT INTO `rain` VALUES (1,1),(2,1),(3,1);
/*!40000 ALTER TABLE `rain` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `temperature`
--
LOCK TABLES `temperature` WRITE;
/*!40000 ALTER TABLE `temperature` DISABLE KEYS */;
INSERT INTO `temperature` VALUES (1,23.62,NULL,NULL,NULL),(2,23.56,NULL,NULL,NULL),(3,23.56,NULL,NULL,NULL);
/*!40000 ALTER TABLE `temperature` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping data for table `timestamp`
--
LOCK TABLES `timestamp` WRITE;
/*!40000 ALTER TABLE `timestamp` DISABLE KEYS */;
INSERT INTO `timestamp` VALUES (1,'2018-07-27 09:29:43'),(2,'2018-07-27 09:29:57'),(3,'2018-07-27 09:30:04');
/*!40000 ALTER TABLE `timestamp` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-07-28 0:00:05
答案 0 :(得分:0)
我认为没有可用的工具,并且没有任何信息就无法还原数据。