Recent

Author Topic: Connect to MySQL via unix socket  (Read 3797 times)

zakiwi

  • New Member
  • *
  • Posts: 28
Connect to MySQL via unix socket
« on: October 11, 2010, 08:23:44 pm »
Hi there,

I am wanting to connect to MySQL server 5.0 with unix sockets as opposed to TCP sockets.

Is that possible (or advisable), and if so, how.

Kind regards

Zakiwi

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: Connect to MySQL via unix socket
« Reply #1 on: October 19, 2010, 06:43:09 am »
#include<mysql.h>
...
..

#define DBHOST "localhost"
#define DBUSER "root"
#define DBPASS "test"
#define DBBASE "accounting"
...
...
MYSQL mysql;
...
...
...

mysql_init(&mysql);
if(!mysql_real_connect(&mysql,DBHOST,DBUSER,DBPASS,DBBASE,0,NULL,0))
{
printf("Error Connecting To Database\n");
free(truncated);
 exit(1);
}

...
...
...


That's the code snippet
Oh, it's c for linux  :D

 

TinyPortal © 2005-2018