Dreaded Access Denied With a strange twist

Dreaded Access Denied With a strange twist

am 04.01.2005 20:22:44 von Sam Boles

------_=_NextPart_001_01C4F292.C3F641EF
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Whenever I try to connect to the MySQL database server using a PHP =
script, I am getting the infamous Access denied message:
=20
Error 1045:Access denied for user ' =
user_name'@'host_name' (using password: YES) (names have been changed =
to protect my server).
=20
The thing that is weird is that I am only getting this problem when =
trying to connect via PHP's built in mysql or mysqli functions (both =
php_mysql.dll and php_mysqli.dll are equally non responsive). ODBC =
(including ODBC via PHP), mysql clients (including the command line =
client as well as the graphic clients MySQL CC and MySQL Administrator) =
and even MySQL PHP Administrator works perfectly--nary a hiccup.
=20
Server environment is:
Apache/2.0.52 (Win32) PHP/5.0.3=20
MySQL client API version 4.1.7
MySQL version 4.1.7 -nt
Windows 2000 Server Service Pack 4
=20
Note that MySQL runs on the default port, but Apache runs on a =
non-standard port. Also, the database/web server machine is for an =
intranet and is accessible only from within the network (its IP address =
is non-routable and there is no NAT that leads directly to this =
machine).
=20
I have gone through and tried all the options in the FAQ's, mail lists =
and expert forums, and have Googled until my fingers are blue. =20
=20
I can tell you reasonably well what the issue is not:
=20
It is not a long- vs.. short- password issue, since this happens with =
Old Passwords on and Old Passwords off.
It is also not a user/password issue, since this is exclusive to PHP =
"direct" connections. ODBC and mysql clients work perfectly.
It is not an issue with the server not running, as I have ASP pages that =
access the data via ODBC connections and interact with several databases =
using the same username/password combinations that do not work here.
It may be the mysqllib.dll, but I have tried several versions of this =
library--both the one that came with PHP 5 and the one that shipped with =
MySQL 4.1.7. Both are equally non-responsive. And, Apache/PHP starts =
quite well, (initially I got the library not found error, but corrected =
this by putting mysqllib.dll in the system32 folder).
It is not a permissions issue, as the username/password combination that =
will not connect via PHP has full permissions and can (and does) =
exercise most of them when connecting via any of the other methods =
listed earlier--including the command line client.
=20
To put it bluntly, I am bamboozled. I have tried everything I can find =
in the mail lists, Google, manuals and online support. Any suggestions =
that might resolve this would be appreciated.
=20
If you want to see it, my script code (that does not work) is as follows =
(again, names modified for security):
=20
For the php_mysql.dll version:
=20
//phpinfo();
if(!($dblink =3D mysql_pconnect ("localhost","user_name","password")))
{
print ("Could not connect to the server!
\n");
print (mysql_errno().":".mysql_error() ."
\n");
exit();
}
else
{
print ("Yahoo!
\n");
}
mysql_select_db ("dbname",$dblink);
=20
?>
=20
The php_mysqli.dll version:
$mysqli =3D new mysqli("localhost", "user_name", "password");
=20
/* check connection */=20
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
=20
printf("Host information: %s\n", $mysqli->host_info);
=20
/* close connection */
$mysqli->close();
?>
=20
Thanks.
=20

We've moved! The Atlanta Community Food Bank has moved into its new home =
on Joseph E. Lowery Boulevard, adjacent to our former Jefferson Street =
warehouse. Please note changes to my address and telephone extension =
below.

Sam Boles =20
Database and Web Administrator=20
Atlanta Community Food Bank=20
25 Years of Nourishing Stronger Communities=20
Atlanta Community Food Bank=20
25 Years of Nourishing Stronger Communities =20
732 Joseph E. Lowery Blvd., Atlanta, GA 30318-6628 =20
ph: 404-892-3333 ext 1220 direct: 678.553.5940 fax: =
678.553.5941=20
sam.boles@acfb.org =
www.acfb.org=20

Atlanta's Table Hunger Walk Product Rescue Center=20
Community Gardening TACK Hunger 101 Kids in =
Need=20

=20

------_=_NextPart_001_01C4F292.C3F641EF--

RE: Dreaded Access Denied With a strange twist

am 05.01.2005 09:42:23 von Tom Molesworth

Sam Boles wrote on Tuesday, January 04, 2005
7:23 PM:

> Whenever I try to connect to the MySQL database server using
> a PHP script, I am getting the infamous Access denied message:
>
> Error 1045:Access denied for user '
> user_name'@'host_name'
> (using password: YES) (names have been changed to protect my server).

Some suggestions:

* mysql differentiates between "localhost" and "external host", so you might
need to have one entry in the grant tables for user@localhost, and one for
user@%, or to try using IP iddress/hostname instead of localhost in the php
script
* try running mysql with --skip-grant-tables, see if it still fails (if so,
probably a php/mysql library problem?)
* see if you can connect from a different computer, such as another server
running apache/phpmyadmin or similar
* maybe even try one of the other prepackaged apache/php collections (like
www.xampp.org or www.wampp.org)

maybe look into php.ini variables controlling mysql connection, switch
between local socket and TCP connection, etc.

cheers,

Tom

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org

RE: Dreaded Access Denied With a strange twist

am 05.01.2005 14:29:17 von Sam Boles

To everyone who responded, thanks for the help.

Late yesterday I finally found (after one last round of hair pulling) =
and corrected the issue. The issue was with the syntax used in the =
connection function (and this affects both mysql and mysqli functions). =


In a nutshell, using double quotes {connection_function =
("localhost","user_name","password")} around the arguments in the =
connection functions caused the issue. Changing this to single quotes =
{connection_function ('localhost','user_name','password')} corrected it.

(One caveat: I do not know if this affects PHP and MySQL on all =
platforms, as I have only tried it on Apache 2 with PHP 5 and MySQL 4.1 =
on Windows 2000.)

In my defense, almost all of the documentation and examples I have found =
in the PHP and MySQL materials both in print and online uses the double =
quote syntax. =20

I intend to post a follow-up with this info to the mail list this =
morning.

Again, thanks for the help.

We've moved! The Atlanta Community Food Bank has moved into its new home =
on Joseph E. Lowery Boulevard, adjacent to our former Jefferson Street =
warehouse. Please note changes to my address and telephone extension =
below.

Sam Boles =20
Database and Web Administrator=20
Atlanta Community Food Bank=20
25 Years of Nourishing Stronger Communities=20
Atlanta Community Food Bank=20
25 Years of Nourishing Stronger Communities =20
732 Joseph E. Lowery Blvd., Atlanta, GA 30318-6628 =20
ph: 404-892-3333 ext 1220 direct: 678.553.5940 fax: =
678.553.5941=20
sam.boles@acfb.org www.acfb.org =
=20

Atlanta's Table Hunger Walk Product Rescue Center=20
Community Gardening TACK Hunger 101 Kids in =
Need=20



-----Original Message-----
From: Tom Molesworth [mailto:TomM@amfax.co.uk]
Sent: Wednesday, January 05, 2005 3:42 AM
To: Sam Boles; win32@lists.mysql.com
Subject: RE: Dreaded Access Denied With a strange twist


Sam Boles wrote on Tuesday, January 04, 2005
7:23 PM:

> Whenever I try to connect to the MySQL database server using
> a PHP script, I am getting the infamous Access denied message:
>=20
> Error 1045:Access denied for user '
> user_name'@'host_name'
> (using password: YES) (names have been changed to protect my server).

Some suggestions:

* mysql differentiates between "localhost" and "external host", so you =
might
need to have one entry in the grant tables for user@localhost, and one =
for
user@%, or to try using IP iddress/hostname instead of localhost in the =
php
script
* try running mysql with --skip-grant-tables, see if it still fails (if =
so,
probably a php/mysql library problem?)
* see if you can connect from a different computer, such as another =
server
running apache/phpmyadmin or similar
* maybe even try one of the other prepackaged apache/php collections =
(like
www.xampp.org or www.wampp.org)

maybe look into php.ini variables controlling mysql connection, switch
between local socket and TCP connection, etc.

cheers,

Tom

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=3Dgcdmw-win32@m.gmane.org