Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Using your FRM file to get Schema and then import idb files..

Дата публикации: 12-11-2020 15:10:00

 This is a topic that overall you never should have to do... Why? Because you created backups right... You have tested and know the backups work so you can just restore those backups and get your lost schema and related data... 
However that one instance in the corner office.. you never got around to setting up.. it not that important... just crashed and now you realize how you actually do use it... 
All is not lost..  
MySQL released their MySQL utilities awhile back and since been replaced more with the MySQL Shell.  
https://downloads.mysql.com/archives/utilities 
https://dev.mysql.com/downloads/shell/
mysqlfrm is still very handy though when needing to pull out the schema from an FRM file in a quick and simple command and it is a simple install. 
mysqlfrm --diagnostic city.frm
# WARNING: Cannot generate character set or collation names without the --server option.
# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
# Reading .frm file for city.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:
CREATE TABLE `city` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(160) DEFAULT NULL,
  `CountryCode` char(12) NOT NULL,
  `District` char(80) NOT NULL,
  `Population` int(11) NOT NULL,
PRIMARY KEY `PRIMARY` (`ID`),
KEY `CountryCode` (`CountryCode`),
KEY `popkey` (`Population`)
) ENGINE=InnoDB;
#...done.
So now that you have the schema you lost... rebuild the DB or table. For the sake of the example, I will say we just lost the city data from the world DB. 
$ cp city.ibd /tmp/  
$ cp city.ibd /tmp/
mysql > LOCK TABLES city WRITE;
mysql > ALTER TABLE city DISCARD TABLESPACE;
cp city.ibd /edb/local/mysql/data/rundeck/
chown tmdba:dba /edb/local/mysql/data/rundeck/city.ibd
mysql > ALTER TABLE city IMPORT TABLESPACE;
mysql > UNLOCK TABLES;
mysql > SELECT COUNT(*) FROM city;
Using your FRM file to get Schema and then import idb files.. appeared first on MariaDB.org


Основное содержимое страницы с новостью.

 This is a topic that overall you never should have to do... Why? Because you created backups right... You have tested and know the backups work so you can just restore those backups and get your lost schema and related data... 

However that one instance in the corner office.. you never got around to setting up.. it not that important... just crashed and now you realize how you actually do use it... 

All is not lost..  

MySQL released their MySQL utilities awhile back and since been replaced more with the MySQL Shell.  

mysqlfrm is still very handy though when needing to pull out the schema from an FRM file in a quick and simple command and it is a simple install. 

mysqlfrm --diagnostic city.frm
# WARNING: Cannot generate character set or collation names without the --server option. # CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
# Reading .frm file for city.frm:
# The .frm file is a TABLE.
# CREATE TABLE Statement:

CREATE TABLE `city` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(160) DEFAULT NULL,
  `CountryCode` char(12) NOT NULL,
  `District` char(80) NOT NULL,
  `Population` int(11) NOT NULL,
PRIMARY KEY `PRIMARY` (`ID`),
KEY `CountryCode` (`CountryCode`),
KEY `popkey` (`Population`)
) ENGINE=InnoDB;

#...done.

So now that you have the schema you lost... rebuild the DB or table. For the sake of the example, I will say we just lost the city data from the world DB. 

$ cp city.ibd /tmp/  

$ cp city.ibd /tmp/
mysql> LOCK TABLES city WRITE;
mysql> ALTER TABLE city DISCARD TABLESPACE;

cp city.ibd /edb/local/mysql/data/rundeck/
chown tmdba:dba /edb/local/mysql/data/rundeck/city.ibd

mysql> ALTER TABLE city IMPORT TABLESPACE;
mysql> UNLOCK TABLES;
mysql> SELECT COUNT(*) FROM city;

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1MySQL How do you restore tablespace07.6313-07-2019
2MySQL Binlogs:: How to recover05.913-07-2019
3Migration of your data from one database to another05.0517-11-2022
4Partial physical database restore for MariaDB and MySQL05.6402-07-2024
5FromDual Backup and Recovery Manager for MariaDB and MySQL 2.3.1 has been released03.7712-08-2024
6FromDual Backup and Recovery Manager for MariaDB and MySQL 2.3.2 has been released04.1622-10-2025
7FromDual Backup and Recovery Manager for MariaDB and MySQL 2.3.0 has been released03.7725-06-2024
8How to downgrade MariaDB or MySQL06.0121-05-2024
9The problem with MySQL foreign key constraints in Online Schema Changes06.6317-03-2021
10Backups Using the MySQL Clone Operation04.9328-07-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 4.63. Источник: mariadb.org.