When mysql is running normally, it is not difficult to view the table structure. But sometimes mysql fails and this method is no longer feasible. When a failure occurs, a new MySQL instance is usually used to restore the current data. Creating a table is a very important step, and we must have other ways to find the table structure. Where is the table structure defined? The user data that is usually of interest is actually stored in the MySQL data directory. The mysql data directory file structure is very clear. • Catalog Mapping Database The structure defined by the table exists in the frm file, and of course the ibdata that manages metadata will also have records. When the frm file exists, it is relatively easy to restore the table structure; Parsing table structure The following are three ways to parse the create table command from the frm file. mysqlfrm mysqlfrm is one of the mysql utilities tools. mysql utilities requires python2 environment and the installation is very simple. $ tar -xvzf mysql-utilities-1.6.5.tar.gz $ cd mysql-utilities-1.6.5 $ python setup.py build $ python setup.py install mysqlfrm supports two modes for interpreting frm: Direct analysis This mode is relatively straightforward, analyzing the frm file byte by byte, extracting as much information as possible. In this mode, the --diagnostic parameter needs to be used. $ mysqlfrm --diagnostic /data/sakila/actor.frm MySQL example analysis This mode uses a new mysql instance to complete the frm analysis work. 1. Spawn from the current MySQL service and use --server to specify the MySQL service $ mysqlfrm --server=root:pass@localhost:3306 --port=3310 /data/sakila/actor.frm Second, start a new MySQL instance and use --basedir to specify the MySQL program path $ mysqlfrm --basedir=/usr/local/bin/mysql --port=3310 /data/sakila/actor.frm --port specifies the port for the new instance to avoid conflicts with the current port 3306. dbsake This is a tool I discovered by chance. It introduces itself in the documentation as follows: dbsake - a (s)wiss-(a)rmy-(k)nif(e) for MySQL The author must be someone who is very experienced with MySQL. The tool is simple and neat from downloading, installing to using. $ curl -s get.dbsake.net > dbsake $ chmod u+x dbsake $ ./dbsake frmdump [frm-file-path] online service There are some online services that also focus on such issues. From the Recover Structure -> from .frm file entry, upload the frm and you will get the create table command. Final Thoughts When using it, you can test multiple tools, compare which tool's recovery commands are more complete and desirable, and choose the best one. refer to: •mysqlfrm official doc •dbsake project doc Summarize The above are the three methods that I introduced to you to restore the table structure of MySQL from the frm file. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Docker: Modifying the DOCKER_OPTS parameter in /etc/default/docker does not take effect
>>: How to build your own Angular component library with DevUI
1. Network Optimization YSlow has 23 rules. These...
Preface Sometimes, we need a floating effect requ...
Table of contents Build Vuex environment Summariz...
Solve the problem that the vue project can be pac...
This article shares with you how to query the sta...
Previous episode review: Yesterday we talked abou...
Environmental Description Server system: Ubuntu 1...
1. Windows Server 2019 Installation Install Windo...
Regarding how to create this thin-line table, a s...
I encountered a very strange problem today. Look a...
The browser displays TIF format images Copy code T...
Occasionally you'll see characters such as ...
JBoss uses Tomcat as the Web container, so the co...
The various HTML documents of the website are con...
Table of contents Install Docker-ce for the devel...