Archive for November, 2008

How to Read MySQL Binary Logs

November 19, 2008 14 comments

mysqllogoMySQL database server utilizes a transaction log to track all of the modifications performed within the databases. This log ensures both that the database is able to recover when abruptly interrupted (such as a loss of power) and that users are able to undo (or “rollback” in database language) the results of a database transaction. Except for the cases where the administrator has disabled or commented out the log-bin parameter in my.cfg file, this log is generated by default. As the name implies, binary log (transaction log) files are written in binary format, but sometimes you may need to examine the content of the transaction logs in text format, where the mysqlbinlog utility will come in handy.

A binlog file normally is named hostname-bin.xxxxx and stored in /var/lib/mysql directory. It cannot be opened and read straight away as it’s a binary file so we can make use of mysqlbinlog command.

For example, to display the contents of the binary log file named localhost-bin.000004, use this command:

mysqlbinlog localhost-bin.000004

The output includes all events contained in localhost-bin.000004. Event information includes the statement executed, the time the statement took, the thread ID of the client that issued it, the timestamp when it was executed, and so forth.

The binlogs are likely to be very huge thus making it almost impossible to read anything on screen. However, you can pipe the output into a file which can be open up for later browsing in text editor:

mysqlbinlog localhost-bin.000004 > filename.txt

To reduce the amount of data retrieved from binary logs, there are several options that can be used to limit the data that is been returned. Among the useful ones are listed below:



The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. For example:

mysqlbinlog --start-datetime="2008-05-22 00:00:00" --stop-datetime="2008-05-29 00:00:00" localhost-bin.000004

For more information, you can take a look at the official mysqlbinlog documentation.

Categories: Databases Tags: ,

Share Keyboard and Mouse with Synergy

November 12, 2008 1 comment

synergy_logoIt’s very usual for a Linux user to work with multiple monitors and machines; It gives a lot of flexibility and a big boost to our performance. But switching between the different keyboards and mice can be a bit tedious.


For this purpose there is a hardware device that allows you to control multiple computers from a single keyboard, video monitor and mouse: a KVM switch. KVM switches are today difficult to find and not very cheap.


Fortunately there is a software approach to KVM switches: Synergy.


Synergy is used in situations where several PCs are used together, with a monitor connected to each, but are to be controlled by one user. You need only one keyboard and mouse on the desk.


Synergy runs on Windows, Linux and MacOS X in command line mode. There are also some cool GUIs like SynergyKM for MacOS X, QuickSynergy for Linux and MacOS X, and the self Synergy GUI for Windows.


The configuration can be done from the command line but trust me, having such great and minimalistic GUIs out there you don’t want to do that.




Okay, okay the main reason why this blog entry does not cover the internal commands is because there is already an excellent documentation that explains step by step the commands you can use with Synergy… You know, why reinventing the wheel.

Categories: KVM Tags: ,