List:MySQL on Win32« Previous MessageNext Message »
From:Akhil  Mehta Date:September 7 2006 5:04am
Subject:Embedded MySQL and Innodb
View as plain text  
Hi all,

I have problem connecting to InnoDB database when using embedded MySQL.
Test program is unable to open 'mysql' database. I am getting following messages:

Able to initialise server
Unknown database 'mysql'
mysql_real_connect() failed

Test program source and envrionmental details are given below.

Environment details are:
=======================
Using mysql-4.1.21-win32, MS VC++ 6.0

* libmysqld.lib and libmysqld.dll are picked up from
mysql-4.1.21-win32\Embedded\DLL\Release
* Database files (ibdata1, ib_logfile0, ib_logfile1) are created with MySQL-4.1.21
Client/Server installed on other computer and it consists of default databases "mysql"
and "test" created during MySQL-installation. I copied them in D:\MySQL.
* MySQL client/server instance is not running.

my.ini is available in C:\ directory and its contents are
=========================================================
[client]

port=3306
default-character-set=utf8

[Mysqltst_SERVER]

port=3306
basedir="C:/Program Files/MySQL/MySQL Server 4.1/"
default-character-set=utf8
language="C:/Program Files/MySQL/MySQL Server 4.1/Share/English"
default-storage-engine=INNODB
datadir="D:/MySQL/"
innodb_log_file_size=10M

Source code of test program:
===========================

#include <windows.h>
#include <winsock.h>
#include <mysql.h>

#include <stdio.h>
#include <stdlib.h>

static char *server_args[] = {
"Mysqltst", /* this string is not used */
"--datadir=D:\\MySQL",
"--key_buffer_size=32M"
};

static char *server_groups[] = {
"embedded",
"server",
"Mysqltst_SERVER",
(char *)NULL
};

int main(void)
{
MYSQL *mysql ;

if (mysql_server_init(sizeof(server_args) / sizeof(char *),
server_args, server_groups))
exit(1);

mysql = mysql_init(NULL) ;
printf("Able to initialise server\n") ;

/* Use any MySQL API functions here */

mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "Mysqltst_SERVER") ;
mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 0);

if(mysql_real_connect(mysql, NULL, NULL, NULL, <<<--- This is failing
"mysql", 0, NULL, 0) == NULL)
{
printf(mysql_error(mysql)) ;
printf("\nmysql_real_connect() failed\n") ;
mysql_close(mysql) ;
exit(1) ;
}

mysql_server_end();

printf("Able to end server\n") ;

return EXIT_SUCCESS;
}


- - - - - - - - -

Warning in Error log file:

060906 11:58:23 [Warning] Can't open and lock time zone table: Table
'mysql.time_zone_leap_second' doesn't exist trying to

live without them

It seems this warning is again due to the fact that test program is unable to open mysql
database.
- - - - - - - - -

Build Log - If some one may find it useful.

--------------------Configuration: testcom - Win32 Release--------------------
Command Lines
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPE4.tmp" with contents
[
/nologo /MT /W3 /GX /O2 /I "C:\Program files\MySQL\MySQL Server 4.1\Include" /D "WIN32"
/D "NDEBUG" /D "_CONSOLE" /D "_MBCS"

/Fp"Release/Mysqlcon.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
"C:\User\VC\Abhay\TestProjects\MySQLTst\File-1.c"
]
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPE4.tmp"
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPE5.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib

odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib

oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmysqld.lib /nologo /subsystem:console
/incremental:no

/pdb:"Release/Mysqlcon.pdb" /machine:I386 /out:"Mysqlcon.exe" /libpath:"C:\Program
Files\MySQL\MySQL Server 4.1\lib"
".\Release\File-1.obj"
]
Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPE5.tmp"
Output Window
Compiling...
File-1.c
Linking...

Results
Mysqlcon.exe - 0 error(s), 0 warning(s)
- - - - - - - - -

Can anyone suggest the possible cause of the problem?

Thanks in advance,
Akhil


Thread
Embedded MySQL and InnodbAkhil  Mehta7 Sep