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 API | brian | 13 Mar |
| • C API | sinisa | 14 Mar |