S
S
Sergey2015-12-25 18:05:57
MySQL
Sergey, 2015-12-25 18:05:57

How, having a backup of /var/lib/mysql/sitename in hand, restore the sitename database?

Hello.
The script made a copy of the hard disk, but for some reason did not make backups through mysqldump.
On the server, I installed mysql from scratch. Created users with passwords from the site config.
I have a complete copy of the /var/lib/mysql/sitename folder
Accordingly, I copy sitename to /var/lib/mysql
And in phpmyadmin it sees the sitename database, but when I try to look at it, it says "No tables found in database", why? The folder contains .frm and .ibd files.
Owner and group on the mysql:mysql
folder I can't just copy the entire folder, the root passwords are different now, and the old ones are forgotten.
In general, the question is this:
How, having a backup of /var/lib/mysql/sitename in hand, restore the sitename database?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Soslan Aldatov, 2015-12-25
@butteff

It seems to me that you can just try to copy this entire folder, and then reset the root password according to the instructions.

Y
Yuri, 2015-12-25
@xtreme

ibd copied from source when MySQL is off? Was innodb-file-per-table enabled in the old MySQL config?
If you copied them with MySQL enabled without using xtrabackup, then with a very high probability you will not start a database. You can try to create empty tables with the same parameters as on the source, then turn off MySQL, put ibd in there, etc.
If innodb-file-per-table was not enabled in the old MySQL config, then all your data remained in the database root in ibdata1.

R
romy4, 2015-12-25
@romy4

Are frm empty?

S
Sergey Zubkov, 2019-05-02
@szubkov

I had exactly the same problem, I tried many, many things, in the end this article helped me a lot, but with some variations from other articles:
www.hexblot.com/blog/recovering-innodb-tables-ibd
-... existing folder /var/lib/mysql/sitename we are left with frm and ibd files.
The plan is something like this:
1. First, we recreate the list of database tables without the exact structure
(only stub tables were created in the article, I personally recreated the table structures somehow using "mysqlfrm --diagnostic [tablename].frm")
2. Restore the exact structure tables
(Turn off mysql, replace only .frm files in the database, turn on mysql with the innodb_force_recovery=5 parameter, extract the dump with the exact structure of the tables.)
3. Reinstall mysql
(now start with the innodb_force_recovery=1 parameter)
4. Import the table structure from step 2
5. Restore the table data over the structure
(Personally, I did almost like in the article, but without further restarting the mysql server)
Namely:
tables with sql "alter table `[tablename]` discard tablespace;"
5.2) Copy existing ibd files to database
5.3) Attach ibd files to each table with sql "alter table `[tablename]` import tablespace;"
PhpMyAdmin cursed a lot during the process, but displayed the database and let it be exported.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question