I don't know how often this might come up for others, but here's a tip for those times you have to specify a path for the data directory (or other args) in server_args at runtime.
mysql_server_init apparently does not copy the strings you supply it. It simply makes use of the pointers. Be sure that any string variables you put in place of the server arguments persist throughout your program or some functions may fail. Here's an example:
Now the function ends and the 'Data' var is obliterated. mysql_server_init will execute correctly, but later, in a different function mysql_real_connect will fail mysteriously, claiming it can't find the specified database.
Seems simple, even obvious. I won't mention how long it took me to trace the problem in my program...
Posted by Pierre de la Tullaye on March 13 2005 1:58pm
It seems that beetwen the version 4.0.24 and 4.1.10 the errmsg.sys format have changed, so if you got some troubles try to use the latest errmsg.sys file !
Posted by Uwe Berckhemer on September 2 2005 8:43pm
If your program crashes while mysql_server_init() on Windows, don't forget to create a directory "data" in the directory in which your .exe is placed. I'tryed about one week for to solve the problem.
User Comments
I don't know how often this might come up for others, but here's a tip for those times you have to specify a path for the data directory (or other args) in server_args at runtime.
mysql_server_init apparently does not copy the strings you supply it. It simply makes use of the pointers. Be sure that any string variables you put in place of the server arguments persist throughout your program or some functions may fail. Here's an example:
char Data[] = "--datadir=c:/blah/blah/blah/";
const char *server_args[] =
{
"this_program",
Data,
"--skip-innodb"
};
mysql_server_init(etc...);
Now the function ends and the 'Data' var is obliterated. mysql_server_init will execute correctly, but later, in a different function mysql_real_connect will fail mysteriously, claiming it can't find the specified database.
Seems simple, even obvious. I won't mention how long it took me to trace the problem in my program...
It seems that beetwen the version 4.0.24 and 4.1.10 the errmsg.sys format have changed, so if you got some troubles try to use the latest errmsg.sys file !
If your program crashes while mysql_server_init() on Windows,
don't forget to create a directory "data" in the directory in which your .exe is placed. I'tryed about one week for to solve the problem.
Add your own comment.