0

I am developing a web page which retrieve data from a seperate mysql server
on the same network
musql_connect('192.16.1.2:3306', 'root', '123');

but ana error shows

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '192.16.1.2' (13) in /var/www/html/index.php on line 3

the 2 servers are on 2 different virtual network (I am using centos on virtual box)

I have set the webserver(apache) on 192.16.1.1
and the mysql on 192.16.1.2

when I tried locally it had worked!

please help

3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by f.damati
0

I am developing a web page which retrieve data from a seperate mysql server
on the same network
musql_connect('192.16.1.2:3306', 'root', '123');

but ana error shows

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '192.16.1.2' (13) in /var/www/html/index.php on line 3

the 2 servers are on 2 different virtual network (I am using centos on virtual box)

I have set the webserver(apache) on 192.16.1.1
and the mysql on 192.16.1.2

when I tried locally it had worked!

please help

This is your problem, not PHP or MySQL. Log into your webserver VM and try to ping your VM running MySQL. You probably can't.

Figure out your VM/network configuration and you php/mysql issue will be fixed.

0

Just noticed a typo - if this code was copy/pasted it's probably your problem:

musql_connect('192.16.1.2:3306', 'root', '123');

^^ should be mysql_connect...

Just thought I'd mention it ;)

0

Thank you, but it is bot copy paste
I have tried to do it locally and it worked,
I have checked the spelling and it is write (mysql_connect....)

0

I have successully pinged both VMs

Did you ping both VMs from you local machine? Try pinging you MySQL vm from you webserver vm. VM To VM. 192.16.1.1 to 192.16.1.2 and preferably on the required port of 3306

From your error, it's the connection specifically that's an issue and is a definite difference between running it locally and the VM.

0

yes I did.
But I think I should configure /etc/my.cnf file and enable networking
does anyone Know how?
thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.