Embedded
Previous  Top  Next


This method is the odd one out of the three available methods, because it accesses your MySQL database directly without the need for a mysql server. The libmysqld.dll (windows) / libmysqld.so (linux) in fact contains a complete MySQL server and your application thus becomes the server. There are two driverproperties to set for the Embedded driver, one is the library to use.

NOTE:
The library specified libmysqld.dll (windows) / libmysqld.so (linux) should be available to your application and installed on the system where you intend your application to run. Also, if you wish to use the embedded driver while designing in the IDE, you should make sure Delphi can find the library as well. Best place is usually to put it in the in your program's directory or the "windows\system32" directory or somewhere along your PATH on windows and in your program's directory or alternatively in system folder which are included in LD_LIBRARY_PATH on linux.

The other property is an Options strings property where you can specify commandline parameters for your "mysql server", for example "basedir=c:/mysql"

SciBit has made it really impossibly easy for you to use the embedded mysql server, in general follow these steps and you will be up and running in no time:
·Get a libmysqld.dll/libmysqld.so from MySQL. You can download the source from MySQL's site and compile it yourself or download just the binary library from there. For convenience SciBit has a pre compiled and latest stable version available on our site as well for free download. Once you have it, put it on your system where both Delphi and your application can get it at runtime, best places: application directory or delphi/kylix bin directory or system32 directory or anywhere on your PATH/LD_LIBRARY_PATH  
·Now before you pick the Embedded driver on you TMySQLServer, you should take note of the following settings which are fully discussed in the MySQL Manual. When the library gets loaded and you do nothing further in your IDE/Application:  
1.the embedded library will try to load it's settings from the standard my.cnf/my.ini files, and more specifically from the "groups" in the file and in the following order - first it will try to get the settings from the "[yourapplicationdirectory\yourapplication.exe_SERVER]" section, then from the "[embedded]" section, then from the "[server]" section. Each setting found in subsequent sections which are the same as a previous one, ex. "basedir=c:/mysql" will override the previous one according to the MySQL Manual. If no section groups are found, your application and/or delphi will crash without warning.  
2.to make distribution simpler for you we have included support for mysql commandline parameters as well. But don't worry, you won't have to start your application with commandline parameters. What you can do is specify the commandline parameters in your TMySQLServer's Params property in an "[embedded]" section, just as you would do in the my.cnf file. In the background we parse these, and pass these settings to the driver's Options property the moment you pick the embedded driver. When you activate the TMySQLServer the MyComponents add the "--" in front of all the settings you specified and give it to the embedded library. Thus without worrying about any my.cnf files and sections, you can do the following:  
 
MySQLServer1.Params.Text := '[embedded]'#13#10'basedir=c:/mysql';  
MySQLServer1.DriverKind := dtEmbedded;  
MySQLServer1.Connected := True;  
 
You can specify any standard mysql commandline parameters this way, not only the basedir.  
 
3.Make sure the database you give the embedded driver is:  
·A valid format of the database, thus if you use the MySQL version 4.0.18 embedded library, don't give the embedded library a MySQL version 3.23 format database. The embedded server might depend on directories or character sets not found in an older format database.  
·Also make very sure that no other MySQL servers are working on the database while your embedded server accesses it as well. You will more than likely corrupt all the data in the database when two servers tries to access the same data.  
 
Advantages
·Main advantage is that you are not dependent on a MySQL server installation on the target machines.  
·Full mysql command and SQL support embedded within your application  
·Distribution would also be a breeze, just one library needs to be installed and reside in your application directory  

Disadvantages
·No multi user access to your mysql database, only one app, your's, might access the data at any given time.  
·The embedded library has a large footprint, usually in the region of ~1MB  
·Depending on your product's distribution and opensource status, you might be liable to buy MySQL client licenses for each application you distribute.