dbTalk Databases Forums  

mysqli connection error

comp.databases.mysql comp.databases.mysql


Discuss mysqli connection error in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
css-discuss.org
 
Posts: n/a

Default mysqli connection error - 09-01-2011 , 04:30 PM






I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306' (60) in /Library/WebServer/
Documents/test/db.php on line 9

This is the code:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (!$mysqli){die('Connect Error: ' . mysqli_connect_error());
}

It isn't saying a permission error. I granted the database
permissions to the root user on the database and global permissions.
How can I troubleshoot the connection? I tried to telnet to the
server. It said connection refused. I am running the php page on my
laptop. The mysql/php server is on a g5. I have it outside the
firewall for testing only. No real data.

Reply With Quote
  #2  
Old   
Peter H. Coffin
 
Posts: n/a

Default Re: mysqli connection error - 09-01-2011 , 06:46 PM






On Thu, 01 Sep 2011 15:52:35 -0700, Michael Vilain wrote:
Quote:
In article
34d0f366-f103-49b6-b2ff-c56c6b97089b...oglegroups.com>,
"css-discuss.org" <janis.rough (AT) gmail (DOT) com> wrote:

I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306' (60) in /Library/WebServer/
Documents/test/db.php on line 9

This is the code:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (!$mysqli){die('Connect Error: ' . mysqli_connect_error());
}

It isn't saying a permission error. I granted the database
permissions to the root user on the database and global permissions.
How can I troubleshoot the connection? I tried to telnet to the
server. It said connection refused. I am running the php page on my
laptop. The mysql/php server is on a g5. I have it outside the
firewall for testing only. No real data.

Connectino error could be that the server isn't running or isn't running
on that port or something else entirely. Have you looked at
/var/log/apache2/error_log and the transfer_log? What do they say?
He said the logs say mysql server is waiting for connection.

But we do need to find out if connections on port 3306 get through to
whatever that IP address is. Which means it's time to fire up telnet on
the webhost and use it to try to connect to the mysql serve.

--
We're the technical experts. We were hired so that management could
ignore our recommendations and tell us how to do our jobs.
-- Mike Andrews

Reply With Quote
  #3  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: mysqli connection error - 09-01-2011 , 07:09 PM



On 9/1/2011 5:30 PM, css-discuss.org wrote:
Quote:
I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306' (60) in /Library/WebServer/
Documents/test/db.php on line 9

This is the code:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (!$mysqli){die('Connect Error: ' . mysqli_connect_error());
}

It isn't saying a permission error. I granted the database
permissions to the root user on the database and global permissions.
How can I troubleshoot the connection? I tried to telnet to the
server. It said connection refused. I am running the php page on my
laptop. The mysql/php server is on a g5. I have it outside the
firewall for testing only. No real data.

Lots of possibilities. For instance, server isn't running, it isn't
running on port 3306, MySQL is configured to not accept connections from
other server, a firewall on one server or the other (or both) is
blocking the attempt...

You need to check the MySQL configuration on the server, especially (but
not limited to) bind-address and port in the [mysqld] section. If that
doesn't fix it, check your firewall on both system.

Also, granting root user permissions on the database is a very bad idea.
MySQL users are completely independent of Unix users, but "root" is
used by a lot of people who aren't real familiar with MySQL - and
therefore is a favorite user to try by hackers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #4  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: mysqli connection error - 09-01-2011 , 09:09 PM



On 9/1/2011 7:46 PM, Peter H. Coffin wrote:
Quote:
On Thu, 01 Sep 2011 15:52:35 -0700, Michael Vilain wrote:
In article
34d0f366-f103-49b6-b2ff-c56c6b97089b...oglegroups.com>,
"css-discuss.org"<janis.rough (AT) gmail (DOT) com> wrote:

I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306' (60) in /Library/WebServer/
Documents/test/db.php on line 9

This is the code:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (!$mysqli){die('Connect Error: ' . mysqli_connect_error());
}

It isn't saying a permission error. I granted the database
permissions to the root user on the database and global permissions.
How can I troubleshoot the connection? I tried to telnet to the
server. It said connection refused. I am running the php page on my
laptop. The mysql/php server is on a g5. I have it outside the
firewall for testing only. No real data.

Connectino error could be that the server isn't running or isn't running
on that port or something else entirely. Have you looked at
/var/log/apache2/error_log and the transfer_log? What do they say?

He said the logs say mysql server is waiting for connection.

But we do need to find out if connections on port 3306 get through to
whatever that IP address is. Which means it's time to fire up telnet on
the webhost and use it to try to connect to the mysql serve.

He tried that, Peter, and the connection was refused.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #5  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: mysqli connection error - 09-02-2011 , 02:45 AM



"css-discuss.org" <janis.rough (AT) gmail (DOT) com> wrote:

Quote:
I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306'
Error 2003 means the TCP connect failed. Either MySQL is not listening
on port 3306 (option "port" in my.cnf) or it is not listening on the
99.something network interface (bind-address) or it is not listening
on the network at all (skip-networking). The other possibility is some
kind of network filter (aka: firewall) between the MySQL- and
PHP-machine.


XL

Reply With Quote
  #6  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: mysqli connection error - 09-04-2011 , 12:26 AM



Quote:
I am getting a connection error. My log file says ready for
connections.

This is the php error I get:
Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect
to MySQL server on '99.XXX.XXX.XXX:3306' (60) in /Library/WebServer/
Documents/test/db.php on line 9
Error 60 from the OS, assuming these codes are fairly well
standardized, is "Operation timed out". This looks like Mac
OS, which seems to use the same codes as UNIX.

Quote:
This is the code:
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if (!$mysqli){die('Connect Error: ' . mysqli_connect_error());
}
"Connection timed out" typically means
- no network connectivity between the systems involved (e.g.
network cable fell out of its socket, WiFi signal loss, using
the wrong network cable, mismatched network speeds, etc.)
- A firewall blocking the connection.
- Attempting to connect to the IP address of a nonexistent or
down host.

on the other hand "connection refused" typically means:
- The host or firewall is *UP*.
- The server that's supposed to be listening on the port isn't
running, or is listening on the wrong IP address/port.
- A firewall is set to actively answer and refuse incoming connections.

If a Mysql server is set up properly to allow *any* remote hosts
to log in, but this host isn't allowed, you're going to get a
successful TCP connection (unless something else is wrong) and a
failed login attempt. This is likely not your problem.


Quote:
It isn't saying a permission error. I granted the database
permissions to the root user on the database and global permissions.
How can I troubleshoot the connection? I tried to telnet to the
server. It said connection refused.
Did you specify *port 3306*? "telnet hostname 3306"?

Having a connection to the *telnet port* fail with "connection refused"
is typical if you are not running a telnet server. (Most systems
turn it off by default. If you must allow remote logins, use ssh
instead - it's much more secure.)


Quote:
I am running the php page on my
laptop. The mysql/php server is on a g5. I have it outside the
firewall for testing only. No real data.
telnet from the web/PHP server to the MySQL server:
"telnet hostname 3306"

Unless you can get a successful connection (telnet says "Connected",
which is likely to be followed by garbage-looking characters, that's
ok) with telnet, chances are MySQL logins are going to keep failing.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.