Search code examples
mysqlcharacterlamp

Viewing a binary file in mysql on my LAMP command line server scrambles my characters


Alright, I'm lost on this one.

I have a sql database on a LAMP server. On that server is a single database called frame and a single table called frame_info with three columns, frame_data(a BLOB), frame_name(varchar), and surgeon_name(varchar). I am adding the binary data through a rather convoluted path, so I wanted to look at the binary data to make sure it arrived intact (I know visually inspecting binary data can be very misleading, I just wanted to take a look). When I get on to look at my BLOB, I do:

mysql> use frame;
mysql> select frame_name from frame_info;

=========

frame_name

=========

frame 1

=========

(looks good)

mysql>select frame_data from frame_info;

the screen displays a bunch of binary data, then should say mysql> _. Instead, all of my characters have been scrambled. This is what selecting the frame_name looks like now: attacked

This is the case for my entire machine. If I use quit to get out of mysql, the rest of my LAMP server uses the same character setup.

How does viewing a file change my entire character profile? How can I fix it?

Thanks in advance!


Solution

  • You're probably running into an issue whereby the binary data has a sequence that your terminal has interpreted as an ANSI terminal code, which your terminal does its best to obey.

    After you exit mysql, try the reset command to restore your terminal.

    You'll probably have more luck using something like MySQL Workbench when viewing binary data.