当前位置:网站首页>6、MySQL数据库的备份与恢复
6、MySQL数据库的备份与恢复
2022-07-26 07:16:00 【小猪VS恒哥】
目录
01、导出数据:生成SQL脚本 ---> 导出数据
(1)在控制台使用mysqldump命令可以用来生成指定数据库的脚本文本。
(2)注意:生成的脚本文本中只包含数据库的内容,而不会存在创建数据库的语句,所以在恢复数据时,需要手动创建一个数据库之后再去恢复数据。
语法:mysqldump -u用户名 -p密码 数据库名>生成的脚本文件需要存放的路径

上述命令指定执行完毕之后,可在F盘下找到mystudent.sql脚本文件

02、恢复数据:执行SQL脚本 -->恢复数据
1、方式一:在DOS窗口下,需要登录mysql
语法:source 脚本文件所在的地址(例如:source F:\mystudent.sql)
注意:
执行SQL脚本需要登录mysql,然后进入指定数据库,才可以执行SQL脚本!!!
在执行脚本时需要先行核查当前数据库中的表是否与脚本文件中的语句有冲突(即需要恢复数据存放的数据库中有没有与恢复数据中的文件重复)
(1)创建一个数据库(例如创建数据库为:mynewstudent))
(2)使用数据库
(3)执行SQL脚本,恢复数据

上述命令执行完毕之后,恢复的数据将存放在mynewstudent数据库中:

2、方式二:在DOS窗口下,不需要登录mysql
语法:mysql -u用户名 -p密码 数据库名<脚本文件所在的地址
例如:mysql -uroot -proot mynewstudent<F:\mystudent.sql
(1)前提:先创建好数据库mynewstudent后,再执行下述命令

上述命令执行完毕之后,恢复的数据将存放在mynewstudent数据库中:

边栏推荐
- Drools(4):Drools基础语法(2)
- NiO implementation
- Drools (4): drools basic syntax (2)
- Apache Dolphinscheduler3.0.0-beta-1 版本发布,新增FlinkSQL、Zeppelin任务类型
- RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV
- Screen: frame paste, 0 fit, full fit
- LTS(Light-Task-Scheduler)
- "Wei Lai Cup" 2022 Niuke summer multi school training camp 1 supplementary question record (acdgij)
- Image annotation software reference
- Flame diagram analysis Flink backpressure
猜你喜欢

RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV

DaemonSet

Flame diagram analysis Flink backpressure

【一库】妙啊!这个库组织npm脚本简直爆炸!

PR字幕制作

从XSS Playload 学习浏览器解码

火焰图分析Flink反压

Yolov5 improvements: add attention mechanism (video tutorial)

Advanced Mathematics (Seventh Edition) Tongji University exercises 2-5 personal solutions

Pycharm的相关配置:改字体样式和大小、更改图片背景、更改控制台输出的字体颜色
随机推荐
Unity3d-异步加载场景、进度条加载
Make a chase game with pyGame
Countdown 2 days! Based on the cross development practice of Apache dolphin scheduler & tidb, you can greatly improve your efficiency from writing to scheduling
C51与MDK共存 Keil5安装教程
【C语言】你真的了解printf吗?(printf典型易错,强烈建议收藏)
How to expand and repartition the C disk?
Wechat applet - from entry to penetration
Become an Apache contributor, so easy!
Common programming shortcut keys of idea (take off after learning the operation)
Relevant configurations of pychart: change font style and size, change picture background, and change the font color of console output
File server fastdfs
JIT中的IR工具与JITWatch的下载,编译及使用
金融任务实例实时、离线跑批Apache DolphinScheduler在新网银行的三大场景与五大优化
Analysis of strong tennis cup 2021 PWN competition -- baby_ diary
RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV
为什么extern使用const修饰的变量会编译不过?
Now the metauniverse is no longer an existence that is only applied to the social field
Do you want to restart the database to replace the license?
Deep learning visualization
从XSS Playload 学习浏览器解码