RSS  

Directed Graph

by Thomas G. Mayfield

MySQL Handler

Ugly hack MySQLHandler for console linux

This is a combination of two scripts. The first is a PHP file (dbLoad.php) that uses MDB2 (from PEAR) to break up the DSN string for you, and print out the result, and the other is a bash shell script (load) that just executes the output from dbLoad.php.

To use, put the files somewhere in your search path, and type ‘load mysql://user[:password]@[server][/database]‘ (stuff in brackets is optional).

It could, of course, to be extended to handle other DSNs that MDB2 is able to parse by writing a function named open_<phptype>. See http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php for information on how the DSNs can be constructed.

MySQLHandler.NET

MySQLHandler sets up a URL handler for mysql:// urls on Windows computers. It’s written in VB.NET. It, of course, requires MySQL Query Browser. This is a program to make it easy to open MySQL query browser. It doesn’t store your profiles, it doesn’t save your passwords—all it does is make it possible to open MySQL Query Browser using a standard URL DSN.

To set it up to work, run the program once, and it should notify you that the URL handler has been created. Whenever you move the executable, run it again and it should let you know that the URL handler key has been updated to the new path. It creates a registry key in HKEY_CLASSES_ROOT for mysql that registers that executable as the handler for all mysql:// URLs.

The code is public domain. I really don’t care what you do with it, or how you do it. If you come up with something interesting, I’m all ears, but there are no requirements. Use it at your own risk, etc.

Updates

  • 2006-12-22 Code updated to be a bit more security- and version-conscious. It now tries to detect the MySQL installation first in HKEY_CURRENT_USER, and only checks HKEY_LOCAL_MACHINE if that fails. On Windows 2k, XP, and 2k3, it will set up the file association in the registry local to the user (HKEY_CURRENT_USER\Software\Classes) rather than global to the machine (HKEY_CLASSES_ROOT).

URLs are expected to be in one of the following formats, and if it’s unable to find the data necessary to start the MySQL Query Browser, it will let you know.

  • mysql://username:password@host:port/database
  • mysql://username:password@host/database
  • mysql://username@host/database

To find the location of the MySQL Query Browser executable, it looks for a key starting with "MySQL Query Browser" under HKEY_LOCAL_MACHINE\Software\MySQL AB. If you’ve not installed the full set of MySQL GUI Tools, you could easily hardcode the location in the code and recompile.

If you have any questions or problems, please email tgmayfield@gmail.com.

Powered by WordPress