這篇文章將為大家詳細講解有關MYSQL SOURCE報錯ERROR: ASCII怎么辦,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
南陽ssl適用于網站、小程序/APP、API接口等需要進行數據傳輸應用場景,ssl證書未來市場廣闊!成為創新互聯的ssl證書銷售渠道,可以享受市場價格4-6折優惠!如果有意向歡迎電話聯系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!由 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 is run in non-interactive mode. Set --bin
ary-mode to 1 if ASCII '\0' is expected. Query: ''.
以前沒見過這個錯誤,于是仔細看了一下。先根據報錯查看--binary-mode的意思:
--binary-mode By default, ASCII '\0' is disallowed and '\r\n' is
translated to '\n'. This switch turns off both features,
and also turns off parsing of all clientcommands except
\C and DELIMITER, in non-interactive mode (for input
piped to mysql or loaded using the 'source' command).
This is necessary when processing output from mysqlbinlog
that may contain blobs.
意思就是ASCII '\0' 是不允許的,除非在binary mode下,為什么會不允許呢?
原因在于一個存文本模式的sql腳本不可能存在'\0','\0'對應ASCII的00,NUL,
我們知道在純文本模式下,任何字符都對應自己的編碼,即使是空格、換行、回車、制表符等
,00 NUL只會在二進制模式的文件中才有,當使用非交互模式的時候,比如
在mysqlbinlog|mysql -u root -p 時候是用會關閉,但是我測試了一下也不行
不管使用pipe管道還是重定向都不行:
[root@testmy ~]# cat test.sql|/mysqldata/mysql5.7/bin/mysql --socket=/mysqldata/mysql5.7/mysqld3307.sock
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: ''.
[root@testmy ~]# /mysqldata/mysql5.7/bin/mysql --socket=/mysqldata/mysql5.7/mysqld3307.sock <test.sql ="" 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: ''.
也許這種方式只有在導入ROW格式的binlog才會用到吧。
下面是重現方式,簡單的代碼:
#include
#include
int main(void)
{
FILE* fd;
char a='\0';
if(!(fd = fopen("test.sql","a+")))
{
perror("error:");
exit(1);
}
fputc(a,fd);
fputc('\n',fd);
fclose(fd);
}
向test.sql寫入一個\0即可,就可以重現了。下面是一個ASCII部分控制字符的截圖
關于“MYSQL SOURCE報錯ERROR: ASCII怎么辦”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
本文題目:MYSQLSOURCE報錯ERROR:ASCII怎么辦-創新互聯
網站URL:http://www.yijiale78.com/article4/csocie.html
成都網站建設公司_創新互聯,為您提供App開發、網站設計公司、服務器托管、面包屑導航、做網站、營銷型網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯