[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[root@Centos ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test ← 连接到测试用的test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases; ← 查看当前存在的数据库
+-------------+
| Database |
+-------------+
| mysql |
| test | ← 确认刚刚被删除的test数据库已经成功被恢复回来!
+------------+
2 rows in set (0.00 sec)
mysql> use test ← 连接到test数据库
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; ← 查看test数据库中存在的表
+-------------------+
| Tables_in_test |
+-------------------+
| test |
+-------------------+
1 row in set (0.00 sec)
mysql> select * from test; ← 查看数据库中的内容
+------+---------------------+
| num | name |
+------+---------------------+
| 1 | Hello,CentOS | ← 确认数据表中的内容与删除前定义的“Hello,CentOS”一样!
+------+---------------------+
1 row in set (0.01 sec)
[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases; ← 查看当前存在的数据库
+-------------+
| Database |
+-------------+
| mysql |
| test |
+------------+
2 rows in set (0.00 sec)
mysql> use test ← 连接到test数据库
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; ← 查看test数据库中存在的表
+-------------------+
| Tables_in_test |
+-------------------+
| test |
+-------------------+
1 row in set (0.00 sec)
mysql> select * from test; ← 查看数据库中的内容
+------+--------------------+
| num | name |
+------+--------------------+
| 1 | Hello,CentOS|
+------+--------------------+
1 row in set (0.01 sec)
mysql> exit ← 退出MySQL服务器
Bye
然后,我们再次运行数据库备份脚本,将当前状态的数据库,再做一次备份。
[root@CentOS ~]# cd ← 回到脚本所在的root用户的根目录
[root@CentOS ~]# ./mysql-backup.sh ← 运行脚本进行数据库备份
[root@sample ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test ← 连接到test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test ← 连接到test数据库
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> select * from test; ← 查看数据库中的内容
+------+----------------+
| num | name |
+------+----------------+
| 1| Hello,CentOS | ← 确认数据表中的内容与被修改前定义的“Hello,CentOS”一样!
+------+----------------+
1 row in set (0.01 sec)
mysql> exit ← 退出MySQL服务器
Bye
以上结果表示,数据库被修改后,用备份后的数据库成功的将数据恢复到了被“篡改”前的状态。
测试后…
测试完成后,将测试用过的遗留信息删除。
[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器
Enter password: ← 输入MySQL的root用户密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.20
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test ← 连接到test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A