Thursday, May 28, 2009

Embedded MySQL = libmysqld - Where is it?? I want to download it??

I have seen this question more than once, and I have answered it more than once, but let me get you the facts here, so you know what to look for:

First, Embedded MySQL isn't necessarily the same thing as libmysqld. Libmysqld is the technically embedded MySQL server in a library, in your application. As far as the MySQL website goes though, this is not necessarily how it works. On the website, Embedded MySQL refers to any kind of embedding of MySQL in an application, be it the "normal" MYSQL Server that has been embedded, or be it libmysqld.

This is confusing, and unnecessary, but I have failed to fix this, although I have tried, and this convention has been in place for so long now, that it is difficult to change (also, it means I can keep my job, as I have to explain this to people frequently. Not the most fun of jobs though).

For anyone wanting to embed MySQL and hasn't used MySQL before, maybe you have Oracle or SQL Server or such experiences, embedding these products with an application is actually rather difficult. There are loads of files, registers to update and such-and-such. As for the MySQL server though, this is not the case. MySQL is dead easy to embed, even the full Server, although there is even less to worry about when using libmysqld.

Libmysqld, as you might know, is a "server in a library" implementation of MySQL, which has a few limitations, but which also has surprisingly low overhead. Have a look in my blog for more posts on libmysqld, or more specifically the post on my libmysqld demo application, available on sourceforge.

So hopefully I have cleared that one up. And then, if we assume that it is libmysqld is what you want, they I guess you want to know where to download libmysqld. And the answer is that you can't. There is no separate download for libmysqld, rather it is included with the usually MySQL Server download. And note that there is no libmysqld with 5.0, neither as a separate download, nor as part of the server download. You have to go with 4.1 or 5.1 to get hold of libmysqld.

So to find libmysqld, you download the appropriate version of the MySQL Server, and then you find libmysqld somewhere there. On Linux, it's in the lib subdirectory, on Windows, it's in the Embedded subdirectory.

So, one last comment on this subject then. Why is there not a separate libmsyqld download? Well, one reason is that, even though libmysqld is a self contained MySQL Server in a library, you still need a few more things, like the MySQL C/C++ includefiles to compile you application and at least one of the MySQL language files, named errmsg.sys, to be able to run the application. Usually, at least during development, you want more things, such as some the MySQL utilities. So having to download the whole MySQL Server, including utilities etc, might not be such a bad idea after all.

But what IS a distinctly bad idea is how we confuse Embedded MySQL with libmysqld, but as I said, it's difficult to change now, and it keeps me on the job (if that last argument is a good thing or not, well I leave that to judge, but at least it means I can have a few beers at the end of the day).

/Karlsson

8 comments:

Eric Muyser said...

Good day Anders, I've enjoyed following your blog, for a while now. Up until now I've been using the stuff from your demo, MySQL 5.1 on Windows, and it's worked good. I switched to Linux (Ubuntu) and it stopped working. I downloaded it from mysql.com, linking libmysqld.a, and including mysql/mysql.h. mysql_library_init() keeps returning 1 (error). I've tried 4.1, and it works fine, and also links much faster. I tried 5.4 but it kept saying "Forcing shutdown of 2 plugins," which apparently means it dislikes my only 2 options ("--datadir=./Data/Database", and "--skip-innodb"). 5.1 doesn't give any error, just returns 1. Do you have any ideas for me? :)

Eric Muyser said...

Actually 5.4 magically started working Anders. Great! :) I'll let you know if I figure out why it wasn't working in the first place (I tweaked some stuff, and wasn't sure if mysqld service was interfering). Keep up the good work!

sonu_singh said...

in your blog you say... "MySQL is dead easy to embed, even the full Server, although there is even less to worry about when using libmysqld."

Is there an tutorial or website that can show me how to embed the "full server" and not libmysqld??

I have been googling for a long time but no answers?!?!

thanks.

Programlayan said...

Hi,
I have to seperated application, first one is writing to db, second one reading from db every 5 secs. DB size is increasing, so writing is successfull, but I could not see records reader application. I only see new records after restarts the reader application. I tried lot of ways, including auto commit mode off, refresh table, free/re-create reader connection component but not sucess, It is working with mysql server but not embedded, do you have any solution for this problem? Thank you

gilad said...

Hello, Can you please a direct link to the sourcecode of libmysqld ? Thanks

gilad said...

Hello, Can you please also post a direct link to the source code of libmysqld please ?

Alina Haris said...

Your blogs are so good and informative, thanks for sharing.
Plots on Installments in Lahore

The Maurya Sir said...

Searching for the ideal Hindi song captions for Instagram to improve your Instagram posts? You’re in the correct place, then! Utilizing Hindi song lyrics and melodies in your Instagram captions can give your feed a special touch. Hindi songs are well renowned for their soul-stirring lyrics and catchy sounds.