CSchantz Wiki

Mysql Restore Procedure

Make a replica working directory in a temp location

mkdir /home/temp/name_ticket_data/mysql

Restore the following files to the directory example

Define the directory for second SQL instance

dir=/home/temp/name_ticket_data/mysql

Set Permissions

chown mysql. $dir -R
chmod 751 /home/temp

Create second SQL instance

Regular

mysqld --datadir=$dir --socket=$dir/socket.mysql --pid-file=$dir/mysql.pid --log-error=$dir/mysql.err --skip-grant-tables --skip-networking --user=mysql &

Force recovery

mysqld --datadir=$dir --socket=$dir/socket.mysql --pid-file=$dir/mysql.pid --log-error=$dir/mysql.err --skip-grant-tables --skip-networking --user=mysql --innodb-force-recovery=4 &

Dump newly restored SQL files to a .sql dump

mysqldump -h localhost -S $dir/socket.mysql databasename > database_name.sql

optional specific table export

mysqldump -h localhost -u root databse_name table_name > table_name.sql

Once done with the second instance it needs to be shutdown

mysqladmin -h localhost -S $dir/socket.mysql shutdown