Welcome, Guest. Please login or register.

Author Topic: Accessing a MySQL db from C  (Read 1023 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline TheMagicMTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2857
    • Show only replies by TheMagicM
    • http://www.BartonekDragRacing.com
Accessing a MySQL db from C
« on: March 15, 2005, 09:33:20 PM »
so I have a simple piece of code that connects to my db. It works if I run it direct on the mysql server..but I want to be able to access that db w/that software on another machine on the internal network. If my server
is for example 192.168.0.7 am I supposed to connect to a specific port?

-Alex
PowerMac G5 dual 2.0ghz/128meg Radeon/500gb HD/2GB RAM, MorphOS 3.9 registered, user #1900
Powerbook G4 5,6 1.67ghz/2gb RAM, Radeon 9700/250gb hd, MorphOS 3.9 registered #3143
 

Offline adolescent

  • Hero Member
  • *****
  • Join Date: Sep 2003
  • Posts: 3056
    • Show only replies by adolescent
Re: Accessing a MySQL db from C
« Reply #1 on: March 16, 2005, 01:22:25 AM »
What connector are you using?  ODBC?  I've only done .Net programming using ODBC, and the native connectors but maybe I can help.
Time to move on.  Bye Amiga.org.  :(
 

Offline TheMagicMTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2857
    • Show only replies by TheMagicM
    • http://www.BartonekDragRacing.com
Re: Accessing a MySQL db from C
« Reply #2 on: March 16, 2005, 03:32:19 AM »
I'm connecting directly using this:

if ( !mysql_real_connect ( &mysql , "localhost" , "username" etc etc


but I ran it on my development machine and substituted 192.168.0.7 which is the ip address to the server which I recieved a could not connect response.  But that same compiled code run on the server gets a connect message.
PowerMac G5 dual 2.0ghz/128meg Radeon/500gb HD/2GB RAM, MorphOS 3.9 registered, user #1900
Powerbook G4 5,6 1.67ghz/2gb RAM, Radeon 9700/250gb hd, MorphOS 3.9 registered #3143
 

Offline adolescent

  • Hero Member
  • *****
  • Join Date: Sep 2003
  • Posts: 3056
    • Show only replies by adolescent
Re: Accessing a MySQL db from C
« Reply #3 on: March 16, 2005, 04:56:42 AM »
The default port is 3306.  Are you specifying this?  (although, if I read the docs correctly, it's not required unless you want to force the connection to use named pipes).
Time to move on.  Bye Amiga.org.  :(
 

Offline TheMagicMTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2857
    • Show only replies by TheMagicM
    • http://www.BartonekDragRacing.com
Re: Accessing a MySQL db from C
« Reply #4 on: March 16, 2005, 12:33:30 PM »
no..I just substitute localhost w/192.168.0.7 ...  
PowerMac G5 dual 2.0ghz/128meg Radeon/500gb HD/2GB RAM, MorphOS 3.9 registered, user #1900
Powerbook G4 5,6 1.67ghz/2gb RAM, Radeon 9700/250gb hd, MorphOS 3.9 registered #3143
 

Offline TheMagicMTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2857
    • Show only replies by TheMagicM
    • http://www.BartonekDragRacing.com
Re: Accessing a MySQL db from C
« Reply #5 on: March 16, 2005, 03:50:07 PM »
ok, after some thinkin.. I think I need to go into mysqlcc and where i have the users setup.. I have @localhost... I need to add @ and that should take care of it.
PowerMac G5 dual 2.0ghz/128meg Radeon/500gb HD/2GB RAM, MorphOS 3.9 registered, user #1900
Powerbook G4 5,6 1.67ghz/2gb RAM, Radeon 9700/250gb hd, MorphOS 3.9 registered #3143