When I upgraded one of my servers from Fedora 20 to 21 recently, I noticed that – among a few other issues – the command line history of my mysql client was missing. Too me, this is valuable information and documentation, even. So I investigated and found, that the file format for the .mysql_history seemed to have changed and the client had just discarded my old data. The new file now contains various characters (including ‘space’) in octal notation and it starts with a special marker line:
_HiStOrY_V2_
I assume that this change might have been caused by either MariaDB or Fedora itself having switched from readline to using libedit.
#!/usr/bin/env php <?php $oldData = file($argv[1]); foreach ($oldData as $line) { readline_add_history($line); } readline_write_history($argv[2]);
The PHP package that comes with Fedora 21 seems to be using the same library. So, after restoring my old .mysql_history from backup it was easily converted to the new format using but a few lines of PHP code:
./convert_history.php ~/.mysql_history.bkp ~/.mysql_history