views:

34

answers:

2

Oftentimes I want to query my MySQL data directly without a server running or without having access to the server (but having read / write rights to the files).

Is there a tool or maybe even a library around to query MySQL data files like it is possible with SQLite? I'm specifically looking for InnoDB and MyISAM support. Performance is not a factor.

I don't have any knowledge about MySQL internals, but I presume it should be possible to do and not too hard to get the specific code out?

Thank you for any suggestions!

+1  A: 

I assume you are doing testing/dev work and dont want to run a server. I had to do this a while ago, and the best I came up with is exporting it to SQL and loading that into memory:

mysqldump -u root -pPASSWORD DATABASENAME TABLENAME > table.sql

HSQLDB is an in-memory relational database for java, you could run the queries into that, do the modification you need and then re-export the .sql file. Bit of a roundabout way of doing it...

jgubby
The problem is I also need to update the data.I'm generally interested in the solution to this problem but just so you know, I'm configuring a new Xen domain with a BASH script and need to update a table before the server starts. I have the data mounted.
MGW
Is the update fairly trivial, could you create a table with placeholders and then replace them? Or do you need to do relational/transactional operations on the tables?
jgubby
A: 

MySQL offers a client library which is basically a miniature server. It's called libmysqld. It is C/C++ only, though. According to the docs, it exports an identical API to the normal C/C++ client library.

MySQL Embedded client library

staticsan
Thank you, that is exactly what I was looking for.I guess one could make a tool that does what I need out of this library. Does anyone know of a command line program which already incorporates this library and connects to any MySQL data directory?
MGW