45IT.COM- 电脑学习从此开始!
DIY硬件教程攒机经验装机配置
设计Photoshop网页设计特效
系统注册表DOS系统命令其它
存储主板显卡外设键鼠内存
维修显卡CPU内存打印机
WinXPVistaWin7unix/linux
CPU光驱电源/散热显示器其它
修技主板硬盘键鼠显示器光驱
办公ExcelWordPowerPointWPS
编程数据库CSS脚本PHP
网络局域网QQ服务器
软件网络系统图像安全
页面导航: 首页 > 设计学院 > 网络编程 > 数据库 >

MySQL数据库自动备份及其被损坏后的恢复方法(5)

电脑软硬件应用网 45IT.COM 时间:2012-01-11 14:00 作者:佚名
[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

Database changed
mysql> update test set name='Shit,Windows';  ← 然后将test中表的值重新定义为“Shit,Windows”(原来为“Hello,CentOS”)
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from test;  ← 确认test中的表被定义的值
+------+--------------------+
| num | name  |
+------+-------------------+
| 1 | Shit,Windows |  ← 确认已经将原test数据库表中的值修改为新的值“Shit,Windows”
+------+-------------------+
1 row in set (0.00 sec)

mysql> exit  ← 退出MySQL服务器
Bye

以上,我们就等于模拟了数据库被篡改的过程。接下来,是数据库被“篡改”后,用备份进行恢复的方法。

 

[root@CentOS ~]# /bin/cp -Rf /backup/mysql/test/ /var/lib/mysql/  ← 复制备份的数据库test到相应目录

然后,再次登录到MySQL服务器上,看数据库是否被恢复到了被“篡改”之前的状态。

 

[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
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------
无法在这个位置找到: baidushare.htm
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片
推荐知识