innodb restore
- knowledgediary4min
- Mar 30, 2020
- 1 min read
Create a new folder:
mkdir /var/lib/mysql2
From R1:
Restore from the /var/lib/mysql folder:
+ The folder which is called the db name (e.g. 'themoder_wordpress')
+ The files: ibdata, ib_logfile0, ib_logfile1
Restore these to /var/lib/mysql2
(Make sure this is mysql2 otherwise you will overwrite the existing mysql instance)
On The Server:
get MySQL to install:
mysql_install_db --datadir=/var/lib/mysql2
Create a my.cnf file in the mysql2 directory:
nano /var/lib/mysql2/my.cnf
and add the following to the file:
[mysqld]
skip-networking
datadir=/var/lib/mysql2/
socket=/var/lib/mysql2/mysql.sock
innodb_data_home_dir=/var/lib/mysql2
innodb_log_group_home_dir=/var/lib/mysql2
skip-grant-tables
[mysql.server]
user=mysql
basedir=/var/lib/mysql2
Update Permissions:
chown -R mysql.mysql /var/lib/mysql2
Run the MySQL Service:
mysqld_safe --defaults-file=/var/lib/mysql2/my.cnf &
Perform a Dump:
mysqldump --socket=/var/lib/mysql2/mysql.sock --databases DB_NAME > /DB_NAME.sql
Import the Dump
DB_NAME < /DB_NAME.sql
Once done, now you can clean up:
Show proccesses and get the PID
ps aux | grep mysql2
Find the Process number and kill it: example:
kill 3408266
Once the Processes are dead, remove the directory:
cd /var/lib/
rm -rf mysql2
Comments