dbTalk Databases Forums  

Connect to MySQL database using UNIX sockets (under Linux)

comp.databases.mysql comp.databases.mysql


Discuss Connect to MySQL database using UNIX sockets (under Linux) in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rob
 
Posts: n/a

Default Connect to MySQL database using UNIX sockets (under Linux) - 09-29-2010 , 06:44 AM






Does anyone know know where I can find protocol information on how to connect to
a MySQL database directly using UNIX sockets (without using libmysqlclient.so)?
I haven't had any luck googling it.

Reply With Quote
  #2  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 09-29-2010 , 06:51 AM






On 9/29/2010 7:44 AM, Rob wrote:
Quote:
Does anyone know know where I can find protocol information on how to
connect to a MySQL database directly using UNIX sockets (without using
libmysqlclient.so)? I haven't had any luck googling it.
You won't - the socket is used internally by MySQL for communications
between the application and the server. What you would need to do is
duplicate the function of libmysqlclient.so, which would be a huge job
(and may change with a different release of MySQL). So you might as
well use libmysqlclient.so (unless you're a glutton for punishment, that
is).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #3  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 09-29-2010 , 06:54 AM



Rob wrote:
Quote:
Does anyone know know where I can find protocol information on how to
connect to a MySQL database directly using UNIX sockets (without using
libmysqlclient.so)? I haven't had any luck googling it.
Why not just grab the sources and see..

http://dev.mysql.com/downloads/mysql/5.5.html

Reply With Quote
  #4  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 09-29-2010 , 09:23 AM



Rob <junkmail3 (AT) lavabit (DOT) com> wrote:

Quote:
Does anyone know know where I can find protocol information on how to connect to
a MySQL database directly using UNIX sockets
Here: http://forge.mysql.com/wiki/MySQL_In...erver_Protocol

Quote:
(without using libmysqlclient.so)?
But why? Are you aware of

http://dev.mysql.com/doc/refman/5.1/en/connector-c.html

?


XL

Reply With Quote
  #5  
Old   
Rob
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 10-01-2010 , 06:37 AM



The Natural Philosopher wrote:
Quote:
Rob wrote:
Does anyone know know where I can find protocol information on how to
connect to a MySQL database directly using UNIX sockets (without using
libmysqlclient.so)? I haven't had any luck googling it.

Why not just grab the sources and see..

http://dev.mysql.com/downloads/mysql/5.5.html
Yeah, there looks to be more to this than I thought: as Jerry noted, this could
be a huge job. I guess I could use the source code and modify it to suit my
purposes but it still would be a big job.

Thanks,
Rob

Reply With Quote
  #6  
Old   
Rob
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 10-01-2010 , 06:38 AM



Axel Schwenke wrote:
Quote:
Rob <junkmail3 (AT) lavabit (DOT) com> wrote:

Does anyone know know where I can find protocol information on how to connect to
a MySQL database directly using UNIX sockets

Here: http://forge.mysql.com/wiki/MySQL_In...erver_Protocol

(without using libmysqlclient.so)?

But why? Are you aware of

http://dev.mysql.com/doc/refman/5.1/en/connector-c.html

?


XL
Thanks - that looks like what I was looking for. It looks to be a bigger job
than I thought though: I really wasn't thinking about authentication.

What I am trying to do is add some database connectivity to some of my CGI
programs. The problem is that they do not use the C standard library (instead
using the Linux API directly) and I'm not sure if pulling in a library will work
(anybody know? The next step probably just have to test and see if it works.)
properly.

I think the approach I am going to take for now is to write a daemon that uses
libmysqlclient.so - I needed an excuse to learn C a little better anyway. ;-)
That way I can probably also cache some data and would give me a database
"abstraction layer" as I would also like to be able to connect to a MS SQL
Server database at some point in the future too.

If anyone knows a better approach, I'm open to suggestions. This is the first
time I've tried to write a database application, so I'm basically learning from
scratch.

Thanks,
Rob

Reply With Quote
  #7  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 10-01-2010 , 06:48 AM



On 10/1/2010 7:38 AM, Rob wrote:
Quote:
Axel Schwenke wrote:
Rob <junkmail3 (AT) lavabit (DOT) com> wrote:

Does anyone know know where I can find protocol information on how to
connect to
a MySQL database directly using UNIX sockets

Here: http://forge.mysql.com/wiki/MySQL_In...erver_Protocol

(without using libmysqlclient.so)?

But why? Are you aware of

http://dev.mysql.com/doc/refman/5.1/en/connector-c.html

?


XL

Thanks - that looks like what I was looking for. It looks to be a bigger
job than I thought though: I really wasn't thinking about authentication.

What I am trying to do is add some database connectivity to some of my
CGI programs. The problem is that they do not use the C standard library
(instead using the Linux API directly) and I'm not sure if pulling in a
library will work (anybody know? The next step probably just have to
test and see if it works.) properly.

I think the approach I am going to take for now is to write a daemon
that uses libmysqlclient.so - I needed an excuse to learn C a little
better anyway. ;-)
That way I can probably also cache some data and would give me a
database "abstraction layer" as I would also like to be able to connect
to a MS SQL Server database at some point in the future too.

If anyone knows a better approach, I'm open to suggestions. This is the
first time I've tried to write a database application, so I'm basically
learning from scratch.

Thanks,
Rob
First of all, use the standard C library. Much better than making
direct Linux calls, and not significantly additional overhead.

But just because you're using Linux calls in your application doesn't
mean your C libraries aren't loaded and running. They are, as they are
used for all kinds of internal stuff. And it doesn't mean you can't use
the MySQL client libraries.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #8  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 10-01-2010 , 09:44 AM



Rob wrote:
Quote:
Axel Schwenke wrote:
Rob <junkmail3 (AT) lavabit (DOT) com> wrote:

Does anyone know know where I can find protocol information on how to
connect to
a MySQL database directly using UNIX sockets

Here: http://forge.mysql.com/wiki/MySQL_In...erver_Protocol

(without using libmysqlclient.so)?

But why? Are you aware of

http://dev.mysql.com/doc/refman/5.1/en/connector-c.html

?


XL

Thanks - that looks like what I was looking for. It looks to be a
bigger job than I thought though: I really wasn't thinking about
authentication.

What I am trying to do is add some database connectivity to some of my
CGI programs. The problem is that they do not use the C standard
library (instead using the Linux API directly) and I'm not sure if
pulling in a library will work (anybody know? The next step probably
just have to test and see if it works.) properly.

I think the approach I am going to take for now is to write a daemon
that uses libmysqlclient.so - I needed an excuse to learn C a little
better anyway. ;-)
That way I can probably also cache some data and would give me a
database "abstraction layer" as I would also like to be able to connect
to a MS SQL Server database at some point in the future too.

If anyone knows a better approach, I'm open to suggestions. This is the
first time I've tried to write a database application, so I'm basically
learning from scratch.

well Its not clear what the constraints are on your client apps.

So its hard to suggest an optimal route.
At some level you are going to need some kid of library to just e.g.
open a socket with.

I am not exactly clear as to what you men by using the Linux API
directly..do you then have your OWN replacement for libc etc?
What the kernel has is pretty basic..and you still need a library of soe
sort to 8uinterface to it.

Of that is what you ARE doing, then the connector.c stuff may well be a
good place to start to roll your own access library. And then write such
stubs as it needs from other libraries to get a working DB access shim..

I get the impression these are embedded clients, and you want to keep
code bloat as low as possible..I've done this and it usually helps to
write your own stripped down libc and stdlib and so on..or as much of it
as you are going to need, anyway. You a lift as much as is needful from
elsewhere of course, but in the end you have to take a clear cut
decision as to whether you use someone elses code, and accept their
bloat and generality, or spend the effort adapting or rewriting it, to
get it to be what you want, and no more, and no less.

Knowing what your constraints are, would help to indicate which approach
is more rational, but it is your decision in the end..







Quote:
Thanks,
Rob

Reply With Quote
  #9  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Connect to MySQL database using UNIX sockets (under Linux) - 10-01-2010 , 12:45 PM



Rob <junkmail3 (AT) lavabit (DOT) com> wrote:
Quote:
Axel Schwenke wrote:

Here: http://forge.mysql.com/wiki/MySQL_In...erver_Protocol

(without using libmysqlclient.so)?

But why?

Thanks - that looks like what I was looking for. It looks to be a bigger job
than I thought though: I really wasn't thinking about authentication.
The bigger problem is the correct handling of all the optional features
and changes between versions.

Quote:
What I am trying to do is add some database connectivity to some of my CGI
programs. The problem is that they do not use the C standard library (instead
using the Linux API directly) and I'm not sure if pulling in a library will work
(anybody know?
If you link with libmysqlclient, you also need to link several more
system libs. I.e. for a standard 5.1 build:

$mysql_config --libs
.... -lmysqlclient -lz -lcrypt -lnsl -lm

I also don't see the point in writing CGI programs without using any
system libs (besides the "fun factor" of course). CGI itself is already
so inefficient, that any savings with regards to libraries make little
sense.

Quote:
I think the approach I am going to take for now is to write a daemon that uses
libmysqlclient.so - I needed an excuse to learn C a little better anyway. ;-)
That way I can probably also cache some data and would give me a database
"abstraction layer" as I would also like to be able to connect to a MS SQL
Server database at some point in the future too.
This sounds strange and I wonder what kind of problem you're trying to
solve that way. I.e. "database abstraction" does not work very well
except for some showroom cases.

If you want to use a generic API to access your database, you could
go for ODBC. And/or have a look at http://sqlrelay.sourceforge.net/

Quote:
If anyone knows a better approach, I'm open to suggestions.
First you should check for alternatives to CGI. Have a look at FastCGI.
Or any API that your HTTP server might have (i.e. APAPI for Apache).
Writing Apache extensions is pretty easy and fun!


XL

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.