MySQL 5.7.12 import cannot create a JSON value from a string with CHARACTER SET #39;binary#39;(MySQL 5.7.12 导入无法从具有 CHARACTER SET binary 的字符串创建 JSON 值)
问题描述
我导出了包含 JSON 列的数据库.迁移到新服务器后,我的导入每次都崩溃并出现如下错误:
I exported my database with JSON columns in it. After I migrated to a new server, my import crashed every time with an error like:
无法从带有 CHARACTER SET 'binary' 的字符串创建 JSON 值
cannot create a JSON value from a string with CHARACTER SET 'binary'
在 stackoverflow 上,我找到了这篇文章,但对我不起作用:mysqlimport 问题set @@character_set_database=binary";这会阻止加载 json 值
On stackoverflow, I found this post but didn't work for me: mysqlimport issues "set @@character_set_database=binary" which prevents loading json values
文件大小为 2GB,无法打开.
The file is 2GB and isn't possible to open the file.
有人想导入我的数据库文件吗?
Anyone has an idea to import my database file?
推荐答案
您可以将正则表达式应用于您导出的 SQL 文本,这会将您的二进制字符串转换为可插入的格式.当我遇到这个问题时,这是我快速而肮脏的修复
You can apply a regex to the SQL text which you exported which will convert your binary strings into an insertable format. This was my quick and dirty fix when I faced this issue
(X'[^,)]*')
CONVERT($1 using utf8mb4)
应用这个正则表达式意味着
Applying this regex means
INSERT INTO json_table (json_column) VALUES (X'7B22666F6F223A2022626172227D');
现在变成
INSERT INTO json_table (json_column) VALUES (CONVERT(X'7B22666F6F223A2022626172227D' using utf8mb4));
这篇关于MySQL 5.7.12 导入无法从具有 CHARACTER SET 'binary' 的字符串创建 JSON 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 5.7.12 导入无法从具有 CHARACTER SET 'binary' 的字符串创建 JSON 值


基础教程推荐
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01