Read the data and spell the SQL statement, and then import. The specific methods are:
(1) When exporting, the hex function is used to read the data, and the binary data is converted into a 16 binary string;
Select HEX (Binfield) from TestTable;
(2) When importing, the Unhex function is used to convert the 16 binary string into the binary data import library;
INSERT INTO TestTable Binfield values (Unhex (@hexstr));
The following code can demonstrate the functionality of hex and Unhex:
SELECT HEX (' This is a test str '), the result of the query is: 746869732069732061207465737420737472
SELECT unhex (' 746869732069732061207465737420737472 '), the result of the query is: The is a test str
You can also directly read 16-character characters, preceded by a string with 0x preamble:
SELECT 0x746869732069732061207465737420737472, query result: This is a test str
Importing and exporting binary data with Hex and Unhex functions in MySQL