Re: [PHP-DB] MySQL - separating web and database servers

2004-03-19 Thread Matthew Vos
Hi Piotr,

Everyone else is suggesting edit all of the code.
Alternatively you could setup an iptables rule which forwards all
incoming requests on 127.0.0.1:3306 (or whatever port your mysql server
is running on) to 192.168.0.1:3306 (repolace 192.168.0.1 wit the IP of
your DB server).

This way if your DB moves again, you change your forward rule.
If, however, you try to put the PHP code on another system, you will
need to either put the DB on the same system, or change the iptables
ruleset for the new webserver.

It's worth a shot.

Matt Vos
On Thu, 2004-03-18 at 03:57, Operator wrote:

 Hi everyone,
 
 I need to put my database server on the another machine - how can I
 configure system(Debian Linux)/php/mysql etc. to make it work without 
 changing all 'localhost' in a hundreds of customer's scripts?
 
 The problem is, when localhost is specified as a host the connection is made
 using unix socket, not TCP (is it possible to change this?). I tried to
 export the socket from database server via NFS, but with no success:
 
 (...)
 munmap(0x2e1f2000, 4096) = 0
 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
 socket(PF_UNIX, SOCK_STREAM, 0) = 3
 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
 connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock}, 
 110)
 = -1 ECONNREFUSED (Connection refused)
 shutdown(3, 2 /* send and receive */) = 0
 close(3) = 0
 (...)
 
 Any ideas?
 
 Regards
 Piotr Babula


Re: [PHP-DB] MySQL - separating web and database servers

2004-03-19 Thread Operator
On 19 Mar 2004 at 9:53, Matthew Vos wrote:

 Hi Piotr,
 
 Everyone else is suggesting edit all of the code.
 Alternatively you could setup an iptables rule which forwards all
 incoming requests on 127.0.0.1:3306 (or whatever port your mysql server
 is running on) to 192.168.0.1:3306 (repolace 192.168.0.1 wit the IP of
 your DB server).
 
 This way if your DB moves again, you change your forward rule.
 If, however, you try to put the PHP code on another system, you will
 need to either put the DB on the same system, or change the iptables
 ruleset for the new webserver.
 
 It's worth a shot.
 
 Matt Vos

OK, this is how I want it, but when connecting with localhost 
in the connection string, unix socket is used, not the 
networking... 

It would be nice to have 

default_connection_with_localhost = unix_socket|loopback

in my php.ini :) Even if one of them is better for most of the 
cases. It's good to have a choice.

PB

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Operator
Hi everyone,

I need to put my database server on the another machine - how can I
configure system(Debian Linux)/php/mysql etc. to make it work without 
changing all 'localhost' in a hundreds of customer's scripts?

The problem is, when localhost is specified as a host the connection is made
using unix socket, not TCP (is it possible to change this?). I tried to
export the socket from database server via NFS, but with no success:

(...)
munmap(0x2e1f2000, 4096) = 0
rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
socket(PF_UNIX, SOCK_STREAM, 0) = 3
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock}, 
110)
= -1 ECONNREFUSED (Connection refused)
shutdown(3, 2 /* send and receive */) = 0
close(3) = 0
(...)

Any ideas?

Regards
Piotr Babula

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Ricardo Lopes
What is the problem in changig localhost in houndreds of scripts, ou can do
that with a script or a good text editor that has the function Replace in
Files... can do the trick.

I dont think that editing the host file to make localhost point to the other
machine is a good practice. :)

- Original Message -
From: Operator [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, March 18, 2004 8:57 AM
Subject: [PHP-DB] MySQL - separating web and database servers


 Hi everyone,

 I need to put my database server on the another machine - how can I
 configure system(Debian Linux)/php/mysql etc. to make it work without
 changing all 'localhost' in a hundreds of customer's scripts?

 The problem is, when localhost is specified as a host the connection is
made
 using unix socket, not TCP (is it possible to change this?). I tried to
 export the socket from database server via NFS, but with no success:

 (...)
 munmap(0x2e1f2000, 4096) = 0
 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
 socket(PF_UNIX, SOCK_STREAM, 0) = 3
 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
 connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock},
 110)
 = -1 ECONNREFUSED (Connection refused)
 shutdown(3, 2 /* send and receive */) = 0
 close(3) = 0
 (...)

 Any ideas?

 Regards
 Piotr Babula

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Operator
On 18 Mar 2004 at 11:15, Ricardo Lopes wrote:

 What is the problem in changig localhost in houndreds of scripts, ou can do
 that with a script or a good text editor that has the function Replace in
 Files... can do the trick.

Changing scripts is not a main factor here (but it's not as simple as it may
seem - consider some encoded php applications, cgi's or some not informed
users who will overwrite changed files with their local copies).

I just wanted to know if it's possible to do this without touching
localhost.

 
 I dont think that editing the host file to make localhost point to the other
 machine is a good practice. :)

I agree. But it doesn't work anyway ;)

PB

 
 - Original Message -
 From: Operator [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, March 18, 2004 8:57 AM
 Subject: [PHP-DB] MySQL - separating web and database servers
 
 
  Hi everyone,
 
  I need to put my database server on the another machine - how can I
  configure system(Debian Linux)/php/mysql etc. to make it work without
  changing all 'localhost' in a hundreds of customer's scripts?
 
  The problem is, when localhost is specified as a host the connection is
 made
  using unix socket, not TCP (is it possible to change this?). I tried to
  export the socket from database server via NFS, but with no success:
 
  (...)
  munmap(0x2e1f2000, 4096) = 0
  rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
  socket(PF_UNIX, SOCK_STREAM, 0) = 3
  fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
  connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock},
  110)
  = -1 ECONNREFUSED (Connection refused)
  shutdown(3, 2 /* send and receive */) = 0
  close(3) = 0
  (...)
 
  Any ideas?
 
  Regards
  Piotr Babula
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Peter Beckman
Change, in the /etc/hosts file, this:

localhost   209.10.33.12# new db server

Hopefully this will work.  Haven't tested, just a suggestion.  Probably
breaks a few other things, but at least mysql will work.

Beckman

On Thu, 18 Mar 2004, Operator wrote:

 Hi everyone,

 I need to put my database server on the another machine - how can I
 configure system(Debian Linux)/php/mysql etc. to make it work without
 changing all 'localhost' in a hundreds of customer's scripts?

 The problem is, when localhost is specified as a host the connection is made
 using unix socket, not TCP (is it possible to change this?). I tried to
 export the socket from database server via NFS, but with no success:

 (...)
 munmap(0x2e1f2000, 4096) = 0
 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
 socket(PF_UNIX, SOCK_STREAM, 0) = 3
 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
 connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock},
 110)
 = -1 ECONNREFUSED (Connection refused)
 shutdown(3, 2 /* send and receive */) = 0
 close(3) = 0
 (...)

 Any ideas?

 Regards
 Piotr Babula

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Ricardo Lopes
in your php.ini you have mysql.default_host, mysql.default_user and
mysql.default_password which are used if:

a) you are not in safe mode
b) you supply no string for those parameters.

But i guess this is not your case, i think this doesnt help, but i had an
ideia, you could set your server (http) to work as a router and make
something like a port-forwarding to the other server, like routers do, one
ip could be used be several machines, depending on the port is accessed the
data is forwarded to that port.

This is just an idea i had right now, i dont know if it can be used or if it
works but and least appears to logical and implementable.
Good luck.

- Original Message -
From: Operator [EMAIL PROTECTED]
To: PHP DB [EMAIL PROTECTED]
Sent: Thursday, March 18, 2004 1:34 PM
Subject: Re: [PHP-DB] MySQL - separating web and database servers


 On 18 Mar 2004 at 11:15, Ricardo Lopes wrote:

  What is the problem in changig localhost in houndreds of scripts, ou can
do
  that with a script or a good text editor that has the function Replace
in
  Files... can do the trick.

 Changing scripts is not a main factor here (but it's not as simple as it
may
 seem - consider some encoded php applications, cgi's or some not informed
 users who will overwrite changed files with their local copies).

 I just wanted to know if it's possible to do this without touching
 localhost.

 
  I dont think that editing the host file to make localhost point to the
other
  machine is a good practice. :)

 I agree. But it doesn't work anyway ;)

 PB

 
  - Original Message -
  From: Operator [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, March 18, 2004 8:57 AM
  Subject: [PHP-DB] MySQL - separating web and database servers
 
 
   Hi everyone,
  
   I need to put my database server on the another machine - how can I
   configure system(Debian Linux)/php/mysql etc. to make it work without
   changing all 'localhost' in a hundreds of customer's scripts?
  
   The problem is, when localhost is specified as a host the connection
is
  made
   using unix socket, not TCP (is it possible to change this?). I tried
to
   export the socket from database server via NFS, but with no success:
  
   (...)
   munmap(0x2e1f2000, 4096) = 0
   rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
   socket(PF_UNIX, SOCK_STREAM, 0) = 3
   fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
   connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock},
   110)
   = -1 ECONNREFUSED (Connection refused)
   shutdown(3, 2 /* send and receive */) = 0
   close(3) = 0
   (...)
  
   Any ideas?
  
   Regards
   Piotr Babula
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Operator
On 18 Mar 2004 at 9:22, Peter Beckman wrote:

 Change, in the /etc/hosts file, this:
 
 localhost   209.10.33.12# new db server
 
 Hopefully this will work.  Haven't tested, just a suggestion.  Probably
 breaks a few other things, but at least mysql will work.

Tested before, doesn't work :(

PB

 
 Beckman
 
 On Thu, 18 Mar 2004, Operator wrote:
 
  Hi everyone,
 
  I need to put my database server on the another machine - how can I
  configure system(Debian Linux)/php/mysql etc. to make it work without
  changing all 'localhost' in a hundreds of customer's scripts?
 
  The problem is, when localhost is specified as a host the connection is made
  using unix socket, not TCP (is it possible to change this?). I tried to
  export the socket from database server via NFS, but with no success:
 
  (...)
  munmap(0x2e1f2000, 4096) = 0
  rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
  socket(PF_UNIX, SOCK_STREAM, 0) = 3
  fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
  connect(3, {sin_family=AF_UNIX, path=/var/run/mysqld/mysqld.sock},
  110)
  = -1 ECONNREFUSED (Connection refused)
  shutdown(3, 2 /* send and receive */) = 0
  close(3) = 0
  (...)
 
  Any ideas?
 
  Regards
  Piotr Babula
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 ---
 Peter Beckman  Internet Guy
 [EMAIL PROTECTED] http://www.purplecow.com/
 ---
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Operator
On 18 Mar 2004 at 14:24, Ricardo Lopes wrote:

 in your php.ini you have mysql.default_host, mysql.default_user and
 mysql.default_password which are used if:
 
 a) you are not in safe mode
 b) you supply no string for those parameters.
 
 But i guess this is not your case, i think this doesnt help, 

Exactly...

 but i had an
 ideia, you could set your server (http) to work as a router and make
 something like a port-forwarding to the other server, like routers do, one
 ip could be used be several machines, depending on the port is accessed the
 data is forwarded to that port.
 
 This is just an idea i had right now, i dont know if it can be used or if it
 works but and least appears to logical and implementable.
 Good luck.

And this is how I want it to be done, but in the localhost 
case unix socket is used, not 127.0.0.1:3306 which I could 
forward wherever I want.

Probably I need to change this behaviour in 
ext/mysql/libmysql/libmysql.c for my installation, but this is 
my last hope (mostly because I'm not a C programist...) If some 
of you could tell me if it's possible without breaking 
something else, or point me to the lines that do the job... I 
suppose the change needed would be quite simple.

PB

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Adam Voigt
I don't understand, your ready to hack the MySQL extension, rather then
just use one of the free text editors, that let you mass replace all
your pages at once (which takes roughly 10 seconds)?


On Thu, 2004-03-18 at 10:15, Operator wrote:
 Probably I need to change this behaviour in 
 ext/mysql/libmysql/libmysql.c for my installation, but this is 
 my last hope (mostly because I'm not a C programist...) If some 
 of you could tell me if it's possible without breaking 
 something else, or point me to the lines that do the job... I 
 suppose the change needed would be quite simple.
 
 PB
-- 

Adam Voigt
[EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread John W. Holmes
From: Operator [EMAIL PROTECTED]

 Probably I need to change this behaviour in
 ext/mysql/libmysql/libmysql.c for my installation, but this is
 my last hope (mostly because I'm not a C programist...) If some
 of you could tell me if it's possible without breaking
 something else, or point me to the lines that do the job... I
 suppose the change needed would be quite simple.

Why are you fighting the obvious so hard? You're not connecting to
localhost by any means so just suck it up and realize that you'll need to
change the code. How are you going to carry all of these hacks over when you
upgrade servers or MySQL versions or put in load balancing, etc, etc...

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread Justin Patrin
Operator wrote:

On 18 Mar 2004 at 14:24, Ricardo Lopes wrote:


in your php.ini you have mysql.default_host, mysql.default_user and
mysql.default_password which are used if:
a) you are not in safe mode
b) you supply no string for those parameters.
But i guess this is not your case, i think this doesnt help, 


Exactly...


but i had an
ideia, you could set your server (http) to work as a router and make
something like a port-forwarding to the other server, like routers do, one
ip could be used be several machines, depending on the port is accessed the
data is forwarded to that port.
This is just an idea i had right now, i dont know if it can be used or if it
works but and least appears to logical and implementable.
Good luck.


And this is how I want it to be done, but in the localhost 
case unix socket is used, not 127.0.0.1:3306 which I could 
forward wherever I want.

Probably I need to change this behaviour in 
ext/mysql/libmysql/libmysql.c for my installation, but this is 
my last hope (mostly because I'm not a C programist...) If some 
of you could tell me if it's possible without breaking 
something else, or point me to the lines that do the job... I 
suppose the change needed would be quite simple.

PB
I agree with all of the others, you should not be hacking your way 
around this as it will make lots of problems. You just need to tell your 
users to switch their scripts to using the new host.

Here's the solutions I use. Put all of your connection info in one 
include and include it any time you need to connect. This way, you have 
only one file to change, ever.

--
paperCrane Justin Patrin
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] MySQL - separating web and database servers

2004-03-18 Thread W. D.
At 09:20 3/18/2004, Adam Voigt wrote:
I don't understand, your ready to hack the MySQL extension, rather then
just use one of the free text editors, that let you mass replace all
your pages at once (which takes roughly 10 seconds)?

Adam is right.  Make backups of all the files, then do the edits.

If you have Windows, Replacem is great:
http://www.Orbit.org/replace/

Does a similar program exist for GUI Linux/FreeBSD?

Start Here to Find It Fast!™ - http://www.US-Webmasters.com/best-start-page/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php