Solved

C API for Mysql to create new database

Posted on 2006-07-11
13
395 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 45

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 45

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to organize data in excel ? 2 115
C#, VS15, StructLayout 1 135
TCP/IP Socket - connection close results in data lost 14 140
IIS Log files on Exchange 2013 server 6 163
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

792 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