#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    TR, Kayseri, __LINE__
    Posts
    92
    Rep Power
    12

    Question how to reach MySQL??


    hi everybody,
    I have linux box, installed RedHat9, MySQL3.23.54, and gcc.
    I want to reach MySQL database server, in C program .
    So MySQL-devel also installed, and MySQL header files(mysql.h, mysql_version.h, mysql_com.h) seems under /usr/include/mysql)
    but the when I compile the c program gives so many parse error refers to mysql.h and also says it could not found my_alloc.h..that mkes me grief as you guessed.
    I wonder if anyone send me simple program that uses Mysql and explicit assertion how to use and configure MySQL header files and libraries. or is there any document expreses this matter in any dark room of the net??

    any helps are apreciated.
    best regards.
    //metin
    $Nobody can know what he can do till he tries!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    16
    Rep Power
    0
    try include this header..

    #include <mysql/mysql.h>
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    TR, Kayseri, __LINE__
    Posts
    92
    Rep Power
    12
    that header aready included. I need simple coding and compiling command (with which options) example actually. thanks.
    $Nobody can know what he can do till he tries!
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    16
    Rep Power
    0
    try this exmp... but in c++

    /* file name : mysql.cpp */
    #include <iostream.h>
    #include <stdio.h>
    #include <mysql/mysql.h>

    #define def_host_name NULL /*host to connect to (default =localhost ip)*/

    #define def_user_name NULL /*user name (default =your login name)*/

    #define def_password NULL /*password (default =none)*/

    #define def_db_name NULL /*database to use (default =none)*/

    MYSQL *conn,mysql;/*pointer to connection handler */

    int

    main (int argc,char *argv [])

    {

    conn =mysql_init (&mysql);

    mysql_real_connect (&mysql,def_host_name,def_user_name,def_password,def_db_name,0,NULL,0);

    if(conn==NULL) cout<<"Error connect to db\n";

    mysql_close (conn);

    //exit (0);

    }

    to compile -> g++ -lmysqlclient mysql.cpp
    to run ./a.out

IMN logo majestic logo threadwatch logo seochat tools logo