OSEC

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.pereiracarclasse.pt)
Date: Tue Aug 23 2005 - 09:20:20 CDT


Sorry for replying to my own post, but here is the manual page of PHP
about mysql functions: http://www.php.net/mysql and specificly to
mysql_connect: http://www.php.net/manual/en/function.mysql-connect.php

Nuno Pereira wrote:
> 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
Estagiário
Carclasse - Comércio Automóveis, S.A.
Lugar Sr. dos Perdões - Ribeirão (Famalicão)
Telf.: 252 330 550 - Tlm: 965 215 076
email: nuno.pereiracarclasse.pt

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql