how to share mysql tables within a LAN

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
lisawebs
Forum Commoner
Posts: 44
Joined: Wed Nov 19, 2003 6:21 pm

how to share mysql tables within a LAN

Post by lisawebs »

In a Windows 2K LAN
I want clients using my php application
to share the same mysql tables on the server.

Questions:
If I start mysql on the server, where the tables are,
do I have to run apache/php on the server too?

I´m having problems in running apache/php on a server as a service,]
lots of errors I don´t understand,
then,
I´m running apache/php/ on each client using my application,

Could this work properly?
Do I have to use on my php program the exact PATH
to where the mysql are?

Thanks Lisa
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

It seems that you are confusing things a bit.....

1-) Make sure the database server is running (let's call it host1)

2-) Now let's get a webserver (call it host2) and make sure all our scripts that are running on this server use the database on host1. (Mind that host1 and host2 could be the same)

3-) Either you let the clients browse to host2, or you replicate the webserver installation and its scripts (this has nothing to do with the database on host1) on each client and let them browse to localhost.


Last time i installed apache on a w2k box, i think i had to enable the service by typing "net start apache" in a dos-box. (Don't kill me if i'm wrong :p) The same goes for mysqld-nt.exe
lisawebs
Forum Commoner
Posts: 44
Joined: Wed Nov 19, 2003 6:21 pm

Sorry, I´m a little confused

Post by lisawebs »

Ok, I´ll be replicating webserver+scripts in all clients
accessing LOCALHOST.

Now, what makes a php program look for mysql tables
in a certain PATH?

For instance, after installing the package phpdev,
doing nothing, php programs automatically look for table names
into the C:\phpdev\mysql\data\

Where is this set up?
What if I change this path and put: K:\mysql\data\ ?

I tried to place this path into the php program together with the
database name, and doeswn´t work.

Also, what makes the link between php and mysql?
My reasoning:
if it´s mysqld-nt.exe, then this must be run on each client
using LOCALHOST, then,
if I want to change the path and access the tables on a server drive (K:\) should be mysql in charge of this?

I appreciate your help

Lisa
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

When talking with mysql, php does not look into a folder...
It uses a tcp (or unix) socket to connect to the server...
lisawebs
Forum Commoner
Posts: 44
Joined: Wed Nov 19, 2003 6:21 pm

then, how can I set up this tcp?

Post by lisawebs »

in order to change the tables location,
in other words, how to put the tables in ther server,
and access from a client machine?
User avatar
bluenote
Forum Commoner
Posts: 93
Joined: Sat Mar 01, 2003 4:59 am
Location: Heidelberg, Germany

Post by bluenote »

Hi,

if i understand your intention, you want to connect some Apache/PHP clients in your LAN with the "one and only" MySQL Server so that they all share the same data.

What you have to do is to add users to the MySQL user table, i. e.

mysql@client1
mysql@client2
...
...

which have the rights to perform the actions you want them to do (READ, WRITE, UPDATE, DELETE, ...); the username can be anything you want. BUT: you should password-protect them!

A typical PHP connection for your client machines could be:

Code: Select all

<?php

$hostname = "server1";
$username = "mysql";
$password = "mysql_passwd";

$dbName = "DBname";
$userstable = "DBtable";

MYSQL_CONNECT($hostname,$username,$password) OR DIE("Database connection failed.");

@mysql_select_db("$dbName") or die("Database not found.");

?>
I have a heterogenous LAN (4 Solaris Servers, three Windows clients, 2 Mac Clients) for myself and this works quite well.

The second important thing is that your MySQL - Server listens to incoming TCP connections.

I hope this helps.

Greez,
- bluenote

P. S.: Apache and PHP must not run on the Server; only if you want to use a browser-based GUI like PhpMyAdmin to administrate it, you have to install them both.

P. P. S.:
timvw: 3-) Either you let the clients browse to host2, or you replicate the webserver installation and its scripts (this has nothing to do with the database on host1) on each client and let them browse to localhost.
This a very good thing, but a lot of work ;-)) we've done this on a much larger LAN using an external RAID system which is mounted on 10 Servers which in turn deliver .... but i think it's only worth the effort if the server load is too high for one machine.
Post Reply