• C

C API for Mysql to create new database


Hi,

I can't create new database using mysql_create_db() under mysql. My setps was as below:
//////
void exiterr(int exitcode)
{
    fprintf( stderr, "%s\n", mysql_error(&mysql) );
    exit( exitcode );
}
main()
{
MYSQL *connection = NULL;
connection = mysql_init(connection);
if( connection )
      printf("\nConnection setup Successful\n");
if(! (mysql_connect(connection,"localhost", "root", "santanu")))
      exiterr(1);
if (mysql_create_db(&mysql,"payroll"))
      exiterr(2);

mysql_free_result(res);
mysql_close(connection);
}      


The O/P is :

Connection setup Successful
Client does not support authentication protocol requested by server; consider up
grading MySQL client
Press any key to continue

Why mysql_connect() does not work?
arijit_rebacaAsked:
Who is Participating?
 
Infinity08Connect With a Mentor Commented:
>> Client does not support authentication protocol requested by server; consider upgrading MySQL client
http://dev.mysql.com/doc/refman/5.0/en/old-client.html
0
 
Infinity08Commented:
Use :

if (mysql_create_db(connection,"payroll"))
0
 
arijit_rebacaAuthor Commented:
It was a typo..
ya... I used it
if (mysql_create_db(connection,"payroll")) ...

I update MYSQL client and put librarys to "....VC98\Lib" .

but now the linker error comes:
Linking...
Test.obj : error LNK2001: unresolved external symbol _mysql_create_db@8
Debug/Test.exe : fatal error LNK1120: 1 unresolved externals


please help me as soon as possible....
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
Infinity08Commented:
Did you put the updated library in the project options (linker) ?
0
 
arijit_rebacaAuthor Commented:
ya I have done this... then also the same error comes

unresolved external symbol _mysql_create_db@8
Debug/Test.exe : fatal error LNK1120: 1 unresolved externals
0
 
arijit_rebacaAuthor Commented:
pls help me as soon as possible....

rgds,
0
 
Kent OlsenData Warehouse Architect / DBACommented:

> _mysql_create_db@8

This appears to be a c++ name.  Either you've installed the wrong library or haven't installed enough libraries.


Kent
0
 
arijit_rebacaAuthor Commented:
Can you say more specifically...what is happening???
becoz 1st I install MySql Server 5. Then VC++. Then I kept all the library files from the location " ......\MySQL\MySQL Server 5.0\lib\opt"  to ".....\VC98\Lib". Now Can u tell me what exact the problem is ? Anythings that I have missed..?


waiting for reply,

0
 
Kent OlsenData Warehouse Architect / DBACommented:


Have you read this article?

  http://dev.mysql.com/doc/refman/5.0/en/building-clients.html

It tells you that you need to add a couple of flags to the load process.

Specifically, add:    -L/usr/local/mysql/lib -lmysqlclient -lz

Kent
0
 
arijit_rebacaAuthor Commented:
I have read the article. But I am working in windows platform. Then how do I specify that.


0
 
arijit_rebacaAuthor Commented:
I specify library in my project through project setting --> link option. But then also the linker error comes. Now what I should do ?
0
 
Infinity08Commented:
Apparently, you need to point the linker to the directory :

    <path_to>\mysql\lib

and link in the libraries "mysqlclient" and "z".

Or just add this to the compiler options (command line) :

    -L<path_to>\mysql\lib -lmysqlclient -lz

if you use a GCC-like compiler

Note that you should replace <path_to> with the correct path of course !
0
 
kaliyugkaarjunCommented:
Hi ,
 I may be wrong but this link says ..............

http://mysqld.active-venture.com/C_API_function_overview.html

mysql_create_db()
Creates a database. This function is deprecated; use the SQL command CREATE DATABASE instead.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.