当前位置:网站首页>Database recovery
Database recovery
2022-08-04 14:16:00 【ink_】
备份
表结构
首先,Enter in the directory where the file is to be storedcmd,Press Enter to enter the command line for operating the directory
After entering the command line
mysqldump命令 备份文件
Note here that my original database name isjx_db
because of special symbols_Therefore, an error that the database cannot be found will be reported during backup,So I copied this database named jxdbnormal backup!
mysqldump -u root -p jxdb > jxdb_bk_20211205.sql
mysqldump -u root -p jxdb student> student_bk.sql
恢复
Recovery here is what I usemysql source命令 As for how to use the other directlymysql -uroot I failed with such command…不知道为啥
原表为
删除一行:
有外键约束,The foreign key constraint must be closed before it can be deleted normally
SET FOREIGN_KEY_CHECKS = 0 ;
DELETE FROM student WHERE sno = 15202101;
恢复student表:
use jxdb;
source X:\ProgramData\SqlBackUp/student_bk.sql
恢复成功!
Note that we do not need to log in when we back upmysql的,
When backing up, you can directly perform command line operations in the directory, but you must log in first when restoringmysql,Restore used heresourcecommand and specify the database
导出
SELECT * FROM sc INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/SC_out.txt';
导出时报错:The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
The reason for the error was found to be the installationmysqlSecurity permissions are restricted,这个选项设置系统变量: secure_file_priv,这个变量被用于限制数据导入的导出操作
用SHOW VARIABLES LIKE “secure_file_priv”;Check out our file paths
解决方案
解决办法
将文件导入到value的目录下 并且要注意sqlUse slashes in statements\才可以!
SELECT * FROM sc INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/SC_out.txt';
导入
报错:Loading local data is disabled; this must be enabled on both the client and server sides
Check to see if import permission is turned on
SHOW GLOBAL VARIABLES LIKE 'local_infile';
change this value to ON,在mysql客户端输入:
set global local_infile=1;
Specify the original path to the file import table!
成功!
LOAD DATA LOCAL INFILE
'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/SC_out.txt'
INTO TABLE sc
也可以导出为html
SELECT * FROM course INTO OUTFILE
‘C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/course_html.html’;
边栏推荐
猜你喜欢
随机推荐
如何才能有效、高效阅读?猿辅导建议“因材因时施教”
Analysis and application of portrait segmentation technology
数据库的基本概念
理论篇1:深度学习之----LetNet模型详解
FreeConfig.h文件
Is there a replacement for the LM2596?LM2576 can
How to play the Tower of Hanoi
CCF GLCC officially opened | Kyushu Cloud open source experts bring generous bonuses to help universities promote open source
1375. 二进制字符串前缀一致的次数-前序遍历法
《社会企业开展应聘文职人员培训规范》团体标准在新华书店上架
Rust from entry to proficient 04-variables
文字编码 - Markdown 简明教程
企业应当实施的5个云安全管理策略
爬虫——selenium基本使用、无界面浏览器、selenium的其他用法、selenium的cookie、爬虫案例
【无标题】
php中的ceil和floo以及round函数「建议收藏」
C# 复制列表
记录都有哪些_js常用方法总结
世间几乎所有已知蛋白质结构,都被DeepMind开源了
B.构造一个简单的数列(贪心)