List:General Discussion« Previous MessageNext Message »
From:brian Date:March 13 1999 2:15am
Subject:C API
View as plain text  
Friends,

I run RedHat Linux 5.1. I have installed MySQL Server, Client and Devel
on the same machine.

The following C++ code

#include <./mysql/mysql.h>
#include <stdio.h>
#include <iostream.h>

MYSQL a_mysql;

void main(void)
{
 if(!mysql_real_connect(&a_mysql, "localhost", "user", "password",
"test", 0, 0, 0))
 {
  cout << mysql_error(&a_mysql) << endl << endl;
  exit(0);
 }

 cout << "Everything went OK!!!" << endl << endl;


}

with the following compile

g++ sqltest.cpp /usr/lib/mysql/libmysqlclient.a -osqltest

(the suggested "g++ -I/path_to_mysql/include/mysql
-L/path_to_mysql/lib/mysql myprogram.c -lmysqlclient" gives a message
that it cannot find mysqlclient)

will run and give the following error message:

Can't connect to MySQL server on localhost (111)

I have also tried "" for the hostname as well as 127.0.0.1 and the
machines alias all with the same result.

I can log into mysql from the command line with:

mysql -u root -p

and mess around just fine.

Any advice would be appreciated.

Thanks,
Brian

Thread
C APIbrian13 Mar
  • C APIsinisa14 Mar