1

I'm 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

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Aerox
  • 669
  • 1
  • 13
  • 28

4 Answers4

2

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

0

I got the same error:

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

When opening MySQL Command-Line Client with the command below:

mysql

So instead, I used the command below, then I could open MySQL Command-Line Client:

mysql -u root -p
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
0

You should not use mysqli_connect_error() if you use mysql_connect().

try

$conn=mysql_connect("localhost", "username_of_Admin", "password_of_Admin");
if(!$conn){
    print mysql_error();
}
RiaD
  • 46,822
  • 11
  • 79
  • 123
  • It's the same thing, but it show the error by the right way: Access denied for user ''@'localhost' (using password: NO) – Aerox Jan 04 '12 at 12:30
  • can you show exact code(with changed password) and exact error message,please? – RiaD Jan 04 '12 at 12:36
  • seems that username and password are empty here – RiaD Jan 04 '12 at 12:36
  • yeah it seems that username and password are empty here but is wrong beacuse i access MySQLQueryBrowser with username:root and password:comp (and it's the administrator user), so the username and password are not empty. The exact code and exact errore message? I've already write them in the last post. – Aerox Jan 04 '12 at 13:37
  • I tried your PHP code and the error is: Access denied for user ''@'localhost' (using password: NO). Exactly as i write before in my first responde to you. – Aerox Jan 04 '12 at 13:39
  • I don't know how, but the solution is that: 1)Open MySQLAdministrator, than Click on the "Startup Variables" item on the left, then the "Security" tab. Check the checkbox for "Disable grant tables." 2) Click the "Service Control" item on the left and then the "Start/Stop Service" tab. 3) Click "Stop Service" -- once the services has stopped, click the button again to start the service. – Aerox Jan 04 '12 at 14:14
  • I'm the administrator of Operating System however i have to disable grant tables (as a bypassing administrator privilegies...very very strange). And yes...I'm really confused about that °_° – Aerox Jan 04 '12 at 14:17
  • BE CAREFUL, i don't know why, but after that solution, my Database MySQL has been "deleted". I have all of databases and tables, but if i open them, i received this error: Error No. 1033 Incorrect information in file: 'filename'. Everything is deleted!! °_° HELP! – Aerox Jan 04 '12 at 14:52
0

From my sense I think you are giving wrong userid or password. check it carefully that your user id and password are correct.

Naseer Panhwer
  • 169
  • 1
  • 1
  • 10