Query returning hex string rather than expected alphanumeric text; RE: mysql8+ default option --binary-as-hex

Viewed 45

This works as expected on one machine:

mysql> SELECT `LengthSHOULD` FROM `LengthAndGrowing` WHERE `LenTmpPltzPerKEY`='InCompletedsLengthCheck_0';
+--------------+
| LengthSHOULD |
+--------------+
| A,B,C,D      |
+--------------+

but on a different computer the same code is giving me this:

mysql> SELECT `LengthSHOULD` FROM `LengthAndGrowing` WHERE `LenTmpPltzPerKEY`='InCompletedsLengthCheck_0';
+----------------------------+
| LengthSHOULD               |
+----------------------------+
| 0x412C422C432C44           |
+----------------------------+

0x41 2C 42 2C 43 2C 44 |||| Hunh : 0x 41 2C 42 2C 43 2C 44 ? , , ,

I have gotten this far... asking mysql about what it is using internally:

mysql> SELECT 
    ->    column_name, 
    ->    character_set_name, 
    ->    collation_name 
    -> FROM information_schema.columns 
    -> WHERE table_name = 'LengthAndGrowing';
+------------------+--------------------+--------------------+
| COLUMN_NAME      | CHARACTER_SET_NAME | COLLATION_NAME     |
+------------------+--------------------+--------------------+
| LenTmpPltzPerKEY | utf8mb4            | utf8mb4_0900_ai_ci |
| LengthSHOULD     | NULL               | NULL               |
| GrowingPains     | utf8mb4            | utf8mb4_0900_ai_ci |
| AccordianString  | NULL               | NULL               |
| TimePLEASE       | utf8mb4            | utf8mb4_0900_ai_ci |
+------------------+--------------------+--------------------+

How should I proceed to unsnarl this?

From the hint in the answer from dcolazin, yep, it was the option --skip-binary-as-hex.

So apparently mysql 8.x+; things were made such that by default in for instance a bash shell and in the mysql running there, binary data returned by queries just gets splashed on the screen in hex.

I wound up creating under dir ~/ a new .my.cnf file and under group [mysql] and [mysqld] and for good measure [server-client] adding the option skip-binary-as-hex Useful resource: the SECTION "Option File Syntax" at MySQL Docs: https://dev.mysql.com/doc/refman/8.0/en/option-files.html#option-file-order


[mysql]
skip-binary-as-hex

[mysqld]
skip-binary-as-hex

[server-client]
skip-binary-as-hex

systemctl restart mysqld

mysql -u thisdelinquentuser -p

and get nice data again.

DBAABA,DBAABB,DBAABC,DBAABD, DBAACA,DBAACB,DBAACC,DBAACD, DBAADA,DBAADB,DBAADC,DBAADD,

1 Answers

0x412C422C432C44 is exactly the hexadecimal representation of A,B,C,D and you might try to use the UNHEX() function. Anyway, it is probably the option --binary-as-hex.

Related