?
Solved

C API for Mysql to create new database

Posted on 2006-07-11
13
Medium Priority
?
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
LVL 46

Expert Comment

by:Kent Olsen
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 46

Expert Comment

by:Kent Olsen
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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