Error 1045 access denied for user 'ODBC'@'localhost' (using password no)

Aerox picture Aerox · Jan 4, 2012 · Viewed 7.5k times · Source

I am absolutely new to this area. I am getting the following difficulty:

When I try the mysql command on the shell, Start->cmd->mysql:

Error 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

I don't know why, because if i try to access in MySql by QueryBrowser it works fine.

If i try to connect by a PHP script:

<?php
$conn=mysql_connect("localhost", "username_of_Admin", "password_of_Admin");
$db=mysql_select_db("db_name");

if (!$conn)
    {
    printf("Connection Error: %s", mysqli_connect_error());
    exit();
    }
?>

I receive the error:

Connection Error:

From Windows MySQL installer: mysql-essential-5.0.27-win32 and mysql-gui-tools-5.0-r6-win32

Answer

admin admin picture admin admin · Feb 2, 2013

for some reason, the ODBC user is the default username under windows even if you didn't create that user at setup time. simply typing

mysql

without specifying a username will attempt to connect with the non-existent ODBC username, and give:

Error 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

instead, try specifying a username that you know, for example:

mysql -uroot -p