Forum Moderators: open

Message Too Old, No Replies

How to connect in mysql database placed in different server?

How to connect in mysql database placed in different server?

         

itnecor

6:19 pm on Feb 24, 2006 (gmt 0)

10+ Year Member



I just wanted to ask if is that possible to connect to a mysql database which is in placed on one server if the script requesting for that connection is coming from another server.

Please advise!

Below is the script that I'm using on establishing database connection.
>>>
define('DB_USER','myusername');
define('DB_PASSWORD','mypassword');
define('DB_HOST','mysql.example.com');
define('DB_NAME','dbcms');

$dbc = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)or die ('Could not connect to dbase:' .mysql_error());
@mysql_select_db(DB_NAME) or die ('Could not select the dbase:' . mysql_error());

[edited by: jatar_k at 6:48 am (utc) on Feb. 25, 2006]
[edit reason] removed specifics [/edit]

wheel

8:17 pm on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first thing is to make sure the host mysql server has networking turned on and port 3306 (I think that's the number) open on your firewalls. I'd expect that both of those are off by default.

Personally, I'd be very suspicious of doing this. Leaving mysql open to the internet makes me very uncomfortable. Suggest you try and find a better way to do this.

wheel

3:01 am on Feb 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just re-read and realized I should be clearer. In my.cnf (the mysql config file, probably in /etc) there's a variable, something like networking=no, or skip-networking; I forget the specifics. Anyway, that needs to be set to enable networking then you need to restart mysqld.

itnecor

5:56 am on Mar 6, 2006 (gmt 0)

10+ Year Member



thank you very much wheel!