db connecting from everyelse except from the website.

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

Moderator: General Moderators

User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

db connecting from everyelse except from the website.

Post by anjanesh »

// 101:101:0:50 is NOT the real ip.
There are 2 servers for this : 1 has the php scripts and the other has the mysql db. So I tried to connect to the mysql db by giving the ip.

Code: Select all

$con=mysql_connect('101:101:0:50','news','skdgh31') or die("Cannot Connect");
But it always gave Cannot Connect.
phpMyAdmin was available at 101:101:0:50:8000 and everything worked OK.
I used MySQL front and it too connected.
Yet my scripts from this site could not connect ?
If someone here replies that the problem lies in the php then please mention what I have to look for in phpinof() ?
Please help. Thanks.
Anjanesh
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

changing 'die("Cannot Connect");' to 'die(mysql_error());', what does that kick out?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Can't connect to MySQL server on 'xxx.xxx.xx.xxx' (10060)
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Why the semicolons in the IP address?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

semicolons ? This exactly how the ouput appeared
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Try

xxx.xxx.xxx.xxx

the semicolon is used to indicate the port like

xxx.xxx.xxx.xxx:n

[edit]
Sorry I mean colon. My eyes aren't what they use to be.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

That colon(port) is sued ONLY to access the phpMyAdmin. The IP without port is for direct connection to db.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

what buddha was talking about is:
anjanesh wrote:

Code: Select all

$con=mysql_connect('101:101:0:50','news','skdgh31') or die("Cannot Connect");
Have you tried to change colons to dots here?
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Re: db connecting from everyelse except from the website.

Post by Buddha443556 »

anjanesh wrote:

Code: Select all

$con=mysql_connect('101:101:0:50','news','skdgh31') or die("Cannot Connect");
Those are three colons? My guess is they're confusing PHP since it does recognize the port in the server arguement.

Code: Select all

$con=mysql_connect('101.101.0.50','news','skdgh31') or die("Cannot Connect");
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Same error. So its not a problem with the port
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Sorry - there was no colon in the code. I mistyped it in here only.
xxx.xxx.xx.xxx does not work
xxx.xxx.xx.xxx:xxxx does not either
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

This is all there is in the phpinfo.

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 3.23.49

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout -1 -1
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off


If there is anything left out that needs to be present please mention. I don;t know abt this but shouln't the ip of the mysql server be present here ?
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Might this pertain to your situation:
I have some problems using MySql in Windows XP Home (don't ask why WXP Home, I'm going to linux next weekend), when using php or mysqlcc I get the message [paredes_yedra] ERROR 2003: Can't connect to MySQL server on 'paredes_yedra' (10060) and I'm trying to set up MySql without network connection it was a really pain.
Check first the my.ini and uncomment the #bind-address 127.0.0.1 and it works.
Don't reinstall mysql.
found that in the comments here: http://dev.mysql.com/doc/mysql/en/Can_n ... erver.html
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

When I run on my local machine connecting to the mysql db - it works. So its not a prob with the mysql db server. But when I uploaded it to the website (different ip so localhost cannot be used for connectivity) it does not connect. So connection is not the prob the script in the wesite connecting to it is.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Are you sure there are no firewall issues? Try 'telnet xxx.xxx.xxx.xxx xxxx' on your webhost (you need shell access for that), where dot-delimited Xs stand for ip and last Xs are the port number used to connect to mysql db.
Post Reply