GIT – As those who own dedicated servers know that they have the possibility to enter in their crashed servers using rescue console they have to know that lots of things can be done on including the recover of databases and much more. I will explain how a database can be recovered using resque console.

When rescue console is started you are asked to choose an operating system to work with. Usually there are 2 or more OS to chose but one of the is the OS that the crashed server used to run. Check that and start console.

Once the rescue console is started just log in with user and given on control panel , pay attention since this is not your password but is just a random password set by console.

After the console has been started there is 1 thing people should know , rescue console is working on RAM and many hosters are limiting the console to work with 1GB or ram and after start is already consuming 8-900M so you can’t do much with the rest of them.

Let’s see how a mysql database can be started in rescue console.

First of all we have to mount old system to work with.

[email protected]~# mkdir /tmp/oldsystem
[email protected]~# mount /dev/sda1 /tmp/oldsystem/
[email protected]~#

So we have mounted old system
A new mysql server must be installed on RAM

[email protected]~# apt-get  mysql-server


[email protected]~#  -y install mysql-server

You will be asked to set root password but you can set any since there is no need of it.
After the mysql server is installed a file must be edited


And change

datadir = /var/lib/mysql


datadir = /tmp/oldsystem/var/lib/mysql

Now just restart mySQL server , login with your OLD user and password.

[email protected]~# /etc/init.d/mysql restart
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
[email protected]~#mysql -u user -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 32310
Server version: 5.1.63-0+squeeze1 (Debian)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
mysql> show databases;
| Database           |
| information_schema |
| test_database      |
2 rows in set (0.00 sec)

mysql> use test_database;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>show tables;
| Tables_in_test_database     |
| table_1                     |
| table_2                     |
| table_3                     |
3 rows in set (0.00 sec)

[email protected]~#

Now let’s export database
We have database *test_database*

[email protected]~# mysqldump -uUSER -pPASSWORD -h localhost test_database > test_database_export.sql
[email protected]~#

Now let’s put it back on remote server (if exists) directly from rescue console
Ensure that on remote server a new database is created else :
login to mySQL with you info

mysql> create database test_database;

Ensure that on new server port 3306 is opened for public else :

[email protected]~#  -I INPUT -p tcp --dport 3306 -j ACCEPT

You can close this port later
Ensure that database user on remote server can login from external hosts
When all these have been done import database

[email protected]~# mysql -uUSER -p -h REMOTE_SERVER test_database < test_database_export.sql
Enter password:
[email protected]~#

That’s all

Print Friendly, PDF & Email



Bài viết liên quan