Solved

C API for Mysql to create new database

Posted on 2006-07-11
13
371 Views
Last Modified: 2009-07-29

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?
0
Comment
Question by:arijit_rebaca
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 17088204
Use :

if (mysql_create_db(connection,"payroll"))
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 200 total points
ID: 17088208
>> 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
 

Author Comment

by:arijit_rebaca
ID: 17089077
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 17089110
Did you put the updated library in the project options (linker) ?
0
 

Author Comment

by:arijit_rebaca
ID: 17089194
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
 

Author Comment

by:arijit_rebaca
ID: 17089398
pls help me as soon as possible....

rgds,
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 45

Expert Comment

by:Kdo
ID: 17089560

> _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
 

Author Comment

by:arijit_rebaca
ID: 17089709
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
 
LVL 45

Expert Comment

by:Kdo
ID: 17089751


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
 

Author Comment

by:arijit_rebaca
ID: 17096623
I have read the article. But I am working in windows platform. Then how do I specify that.


0
 

Author Comment

by:arijit_rebaca
ID: 17096636
I specify library in my project through project setting --> link option. But then also the linker error comes. Now what I should do ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 17097152
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
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17098092
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now