linux备份mysql文件并恢复的脚本,以及其中出现的错误:ERROR: ASCII '\0' appeared in the statement...

首先是在网上找了一下教程,代码很简单

#!/bin/bash


folder=~/test
time=`date +%Y%m%d`

mysqldump -u user -p pwd -hlocalhost databasename | gzip > $folder/databasename_$time.sql.gz
#
find $folder -name 'databasename_*.sql.gz' -type f -mtime +7 -exec rm {} \;
#
gunzip < $folder/databasename_$time.sql.gz | mysql -hlocalhost -uuser -ppwd databasename

因为写python代码习惯了,碰到=就自然而然敲空格,结果很多变量都没有值,所以这里需要注意一下,然后user和pwd就是你自己数据的用户名和密码,databasename就是你要操作的数据库名称,因为不想浪费内存就直接将mysqldump生成的sql文件进行了压缩处理,然后中间的命令就是找到七天以前的文件并进行删除操作,-exec是值后面的命令将会被执行,大括号是被执行对象集合,后面以分号结尾,加一个反斜杠防止被转义,第三行命令就是从gzip文件中恢复数据到数据库,一开始我是用gzip,然后就报了一个错误:

ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: '.

我去搜索了一下发现没有什么好的解决方案,然后把sql语句解压后用命令发现可以执行.sql文件,就试了一下不使用gzip改用gunzip,然后就脚本就成功运行并且没有相类似的报错了。

后面的定时执行也顺带提一下,

# chmod +x bashname.sh  --为脚本添加执行权限
# crontab -e
00 3 * * * root ~/bashname.sh
# 表示每天3点00分执行脚本

然后重启一下crontab就可以了。

转载于:https://www.cnblogs.com/zzy0306/p/8858093.html

【go-libp2p学习笔记】使用go-libp2p搭建中转服务器(circuit relay server) libp2p算是一个蛮新的库,提供了非常强大的p2p节点发现/连接/通信能力。IPFS的基石。 中文网上的**技术教程**比较少,所以抛砖引玉开一点坑来体验一下! 阅读详情

相关推荐

【YOLOv8改进 - 注意力机制】GAM(Global Attention Mechanism):全局注意力机制,减少信息损失放大全局维度交互特征

为了提高各种计算机视觉任务的性能,研究了多种注意力机制。然而,现有方法忽视了保留通道和空间两个方面信息的重要性,以增强跨维度的交互。因此,我们提出了一种全局注意力机制,通过减少信息损失和放大全局交互表示来提升深度神经网络的性能。我们引入了带有多层感知器的3D排列用于通道注意力,同时结合了卷积空间注意力子模块。在CIFAR-100和ImageNet-1K上的图像分类任务评估中,表明我们的方法在ResNet和轻量级MobileNet上稳定地优于几种最新的注意力机制。

专注于图像领域,主要研究内容包括计算机视觉和深度学习,特别是在图像分类、目标检测和图像生成等方面有深入的研究和实践经验。 1135

sql_ERROR: ASCII

ASCII '\0' 引起的MYSQL SOURCE错误 今天在群里面有一个朋友给出一个错误: source test.sql ERROR:  ASCII '\0' appeared in the statement, but this is not allowed unless option  --binary-mode is enabled and mysql

borayolo的博客 3821

《人工智能基础》[工具篇2]:ChatBox怎么使用本地模型和知识库配置教程

通过设置-知识库,添加,填入知识库名称、选用的嵌入模型创建好知识库后,点击添加文件按钮+,可以上传本地文件、拖动文件支持上传PDF、DOCX等格式的文档。系统会自动对文档进行处理。批量上传:一次最多上传 50 个文档,总大小不超过 2GB;格式检测:支持 PDF/DOCX/TXT/Markdown,不支持 EXE/RAR 等二进制文件。‌文档类‌图片类‌代码类‌:Python、Java、JavaScript等编程文件‌其他‌:Markdown(用于导出对话记录) ‌。

专注大数据、云计算、人工智能、机器人领域技术传播 2841

mysql 必知必会导入官方数据库,出现错误ASCII\0appeared in the statement解决方法

最近在学MySQL必知必会,导入自带的数据库,出现如下错误ERROR: ASCII\0appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII\0’ is expected. Query: ‘?s’. 解决方法是: 另存为ut

weixin_52643599的博客 2239

MySQL执行脚本出现问题:ASCII\0appeared in the statement

mysql不同系统导入导出问题:ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled

Nio 1784

mysql source error_MYSQL SOURCE报错 ERROR: ASCII

展开阅读全文由 ASCII '\0' 引起的MYSQL SOURCE错误今天在群里面有一个朋友给出一个错误:source test.sqlERROR:ASCII '\0' appeared in the statement, but this is not allowed unless option--binary-mode is enabled and mysql is run in non-i...

weixin_36135382的博客 2324

导入mysql文件提示ERROR:ASCII\o‘ appeared in the statement,

用powershell不行,我换成cmd进行就可以了。

m0_62165705的博客 588

mysql生成ascii格式文本文件_linux备份mysql文件恢复脚本,以及其中出现的错误ERROR: ASCII '\0' appeared in the statement...

首先是在网上找了一下教程,代码很简单#!/bin/bashfolder=~/testtime=`date +%Y%m%d`mysqldump-u user -p pwd -hlocalhost databasename | gzip > $folder/databasename_$time.sql.gz#find $folder -name 'databasename_*.sql.gz' -...

weixin_36357900的博客 291

linux mysql密码转义_linux备份mysql文件恢复脚本,以及其中出现的错误ERROR: ASCII '\0' appeared in the statement...

首先是在网上找了一下教程,代码很简单#!/bin/bashfolder=~/testtime=`date +%Y%m%d`mysqldump-u user -p pwd -hlocalhost databasename | gzip > $folder/databasename_$time.sql.gz#find $folder -name ‘databasename_*.sql.gz‘ -...

weixin_42513216的博客 346

window环境下mysql导入sql文件报错ERROR: ASCII '\0' appeared in the statement

错误信息: ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is exp...

weixin_30872733的博客 1656

mysqldump 导出来的文件,使用 source还原时报错ASCII '\0' appeared in the statement, but this is not allowed unless...

导出语句:mysqldump -uroot -pword --databases db1 --tables table1 > ./sqldumps/archive-table1-`date +"%Y%m%d_%H%M%S"`.sql 导出后,使用source还原 报错ASCII '\0' appeared in the statement, but this is not allow...

darling331的博客 1232

导入mysql文件报错ERROR: ASCII\0appeared in the statement, but this is not allowed unless option --bin

在win10的PowellShell备份的sql文件linux上导入都会报这个错误,改成在cmd下导出sql文件就行了,注意这个坑 导出:mysqldump -u用户名 -p 数据库名 > 备份.sql 导入:mysql -u用户名 -p 数据库名 < 备份.sql 可以在PowellShell下远程拷贝文件到你的服务器 打开PowellShell输入: 文件:scp 备份.sql 远程用户名@远程ip: 远程目录/ 目录:scp -r 本地目录 远程用户名@

qq_44657868的博客 4390

一次简单的ASCII故障处理

一次简单的故障记录 ASCII 故障 ASCII\0appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII\0’ is expected. Query: ‘?-’. 执行导出SQL 报这个错误 使用命令 file+文件名查看文

jy4207460的博客 2094

mysql报“ASCII\0appearedinthestatement

mysql报"ASCII\0appearedinthestatement" (2018-12-20 13:55:49)转载▼ mysql 执行sql文件时报: ERROR : ASCII\0appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if

ACBC12345的博客 2896

导入mysql文件提示“ASCII '\0' appeared in the statement

在windows服务器上导入mysql文件时,出现以下报错ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if

全栈空间 2万+

使用source在命令行中导入表时出现ASCII '\0'的错误

使用source 导入表时出现 ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '...

sinat_32768139的博客 1879

ERROR: ASCII\0appeared in the statement, but this is not allowed unless option --binary-mode is

摘要:在导入SQL文件时出现ASCII '\0'错误,原因是解压ZIP文件时目标文件夹无写入权限,导致解压失败误将ZIP文件作为SQL导入。解决方法是为目标文件夹开放写入权限。(94字)

qq_36957701的博客 411

关于ASCII\0appeared in the statement, but this is not allowed...的一个解

使用命令往数据库中导入表的时候出错。

weixin_61133168的博客 941

mysql导入.sql报错

ERROR: ASCII\0appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII\0’ is expected. ...

有记忆的鱼的博客 607

mysqllinux环境下导出,window下导入报ASCII '\0' appeared in the statement

mysql --binary-mode=1 -hIP -uUSER -pPWD -PPORT sql>use database; sql>source /PATH/tbl.sql

qwe3642的博客 837

mysqldump 导出来的文件,使用 source还原时报错ASCII\0appeared in the statement, but this is not allowed unless

选项在MySQL中指示使用二进制模式进行数据传输。这意味着MySQL将数据作为二进制流传输,而不会对其进行字符集转换。这在处理特殊字符或二进制数据时非常有用,可以确保数据的完整性和准确性。在使用source之前连接数据库使用--binary-model=1选项进行连接mysql。这样就会以二进制模式连接到MySQL数据库,对于特殊字符或二进制数据的处理更加可靠。

qq_43285043的博客 708

【JavaWeb】Mysql source 恢复数据出错解决

MySql cmd恢复数据库报错ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --bi nary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII

哈哈哈哈哈哈哈 2449

基于MLX90640和STM32的动态温度监测系统.zip

基于MLX90640和STM32的动态温度监测系统

zabbix监控山石系列Hillstone监控模版(适用于zabbix7及以上)

zabbix监控山石系列Hillstone监控模版(适用于zabbix7及以上)

上一篇: [日常] Go语言圣经-错误,函数值习题
下一篇: Heap(堆结构/优先队列)-Swift实现
weixin_33843409
博客等级 码龄11年 6118粉丝 705原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值