MysqL数据库备份和恢复数据

本文介绍了在Centos 7.3系统中如何进行MySQL数据库的冷备份及数据恢复。首先,模拟了数据库被删除的情况,接着通过两种恢复方式详细阐述了数据恢复过程,包括备份数据库目录和恢复数据的具体操作。在恢复过程中,强调了需修改文件的属主和属组为mysql,以确保数据库服务能正常访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境准备:
系统: Centos 7.3

[root@ localhost backup]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
# 创建备份的目录
mkdir /backup
# 备份命令
mysqldump -uroot -p123 test > /backup/test.sql
cd /backup/
[root@ localhost backup]# ls
test.sql
[root@ localhost backup]# more test.sql 
-- MySQL dump 10.14  Distrib 5.5.64-MariaDB, for Linux (x86_64)
--
-- Host: localhost    Database: test
-- ------------------------------------------------------
-- Server version	5.5.64-MariaDB

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

模拟数据库被删除恢复数据

[root@ localhost backup]# mysql -uroot -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| szm                |
| test               |
| testdb             |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [(none)]> drop database test;
Query OK, 1 row affected (0.06 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| szm       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值