Hi,

I try to connect to a database with the following code.

#define host "192.168.105.105"
#include "mysql.h"

MYSQL mysql;

int exiterr(int i)
{
         fprintf(stderr,"%s\n",mysql_error(&mysql) );
         exit(i);
}

int main(void)
{
         /* ..... */

         if (!(mysql_connect(&mysql,host,"usr1","abc123")) )
                 exiterr(1);
         fprintf(stderr,"Connected to database!\n");
         if (mysql_select_db(&mysql,"test"))
                 exiterr(2);
         fprintf(stderr,"Connected to test database!\n");

         /* ..... */
}

When trying from the same machine, everything works fine, but if I try to 
access the same database from some other machine(not having mysql), it 
connects to the database, but fails to find the database file. The output 
of the program is as follows:

$ ./db
Connected to database!
Unknown database 'test'
$

What is happening? Is it because the client machine does not have mysql 
installed? I compiled the program and ftp ed the binary to the other 
machine. What should I do now?

Please help me. Thanks,
Praveen.

Reply via email to