|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: 'ODBC'
'localhost' instead of 'root'
'invalid_hostname.com' ?!??
From: Nuno Pereira (nuno.pereira
carclasse.pt)
Date: Tue Aug 23 2005 - 08:43:18 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Martin Olsson wrote:
> Hi,
>
> I'm using PHP/MySQL to development a web-based application. I just
> upgraded both PHP and MySQL and I noticed that some of my MySQL calls
> are now broken and I don't see any easy way to fix them.
>
> My script calls mysql_connect() and does very careful error checking.
> It's important that I can tell apart invalid hostname errors from say
> incorrect username/password errors. Previously, I did this by checking
> mysql_errno(), where 2003 would mean bad hostname and 1045 would
> indicate bad username/password.
>
> In the latest PHP/MySQL bundle I downloaded this functionality changed
> though. In this new version, whenever I feed it with a invalid hostname
> it will fallback to localhost (where I actually have a database running)
> and then it will subsequently report a 1045 instead of a 2003.
>
> Oddly enough, the exact error message (mysql_error) I get attached to
> this 1045 says; mysql_error()==
>
> Access denied for user 'ODBC'
'localhost' (using password: NO)
This means that, the user "ODBC" (without quotes) on mysql machine
"localhost" (without quotes, again), can't login to the server without
using a password (the part of "(using password: NO)"). The error number
is correct, bacause you have invalid username/password on that server
(for user ODBC).
> Now, what is this about? I sure did not feed it with a username 'ODBC'.
> I do use Windows 2005 but how could ODBC possibly be related to this? (I
> assume ODBC means that [Microsoft?] database connection thing, I'm not
> sure exactly what is it; i've never used it). For the record, the actual
> username I specified in the call with the invalid hostname was "root".
It seems that you did not specified correctly the username to access the
server, and without password.
The correct syntax is, in your case,
$link = mysql_connect("localhost", "root", "mysql_root_password");
I strongly sugested that you provide a password to root, and login as
another user with your PHP application, obviously with a password. So,
in that case, change the mysql_connect() invocation to something like this:
$link = mysql_connect("localhost", "php_app_user", "user_password");
(Obviously, replace user_password with the password for your
php_app_user of your mysql server).
> ---
>
> So, the question is how can I tell these errors apart?
>
> Why is mysql_error() reporting back that it tried to connect to
> localhost as user "ODBC" when I asked it to connect to an invalid
> hostname as user "root" ?!?!
> sincerly,
> martin
--
Nuno Pereira
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]