Mysql – How to restore database from /var/lib/thesql

disaster recoverylinuxMySQLrecoveryrestore

I have a database folder from a crashed server called gain_wordpress. I'm trying to put that database on a new server but I'm not able to do it successfully. I don't have a .sql dump, all I have is the database folder from a past crashed server with ibdata and the 2 log files.

I copied the gain_wordpress folder to /var/lib/mysql on the new server but when I do a > show tables on the database I get the following error:

ERROR 1018 (HY000): Can't read dir of './gain_wordpress/' (errno: 13)

I also changed the permission of the folder and did a chown mysql:mysql gain_wordpress -R and it still didn't take care of the problem.

What is the best way to recover gain_wordpress. Do I need to replace any of the ibdata or the logfiles? What is the best way? I have the corresponding .frm, .MYD and .MYI files for each table. Please advise.

Best Answer

you need to make sure the ownership and privileges are correct for the directory, you can use the following commands to set it right:

chown -R mysql:mysql /var/lib/mysql/ --your mysql user may have different name, if its different you need to change it [mysql:mysql] as needed 
chmod -R 755 /var/lib/mysql/

note: -R: recursive fir the directory and all its contents.