Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied for user 'ODBC'@'localhost' <using password: YES>

Tags:

mysql

I'm getting an error: mysqladmin.exe: connect to server at 'localhost' failed error: 'Access denied for user 'ODBC'@'localhost' (using password: YES)'

I tried to grant privileges

mysqladmin.exe grant all ON *.* TO 'myuser'@'localhost'

I'm trying to create a database with:

CD C:\Program Files\MySQL\MySQL Server 5.5\bin
mysqladmin.exe create database comersus -p

I just installed MySQL 5.5.27.2 I created a user called myuser I'm working in XP Pro sp3

Please let me know the correct command line to (I think I need to grant permission first) Create a database file.

like image 212
Docfxit Avatar asked Aug 23 '12 01:08

Docfxit


People also ask

How do I fix access denied in MySQL?

You will get this error when the user user_name does not have the right to access your MySQL database. To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password';

How do I fix error 1045 28000 Access denied?

How to fix “Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes)”? It arises when you perform a fresh installation of MySQL and try to login with a password. The default password of MySQL is blank () (i.e. empty string). So, you can login to the MySQL server using the same password.


3 Answers

Try running the mysql command with the following option:

C:> mysql -u root

This specifies the "root" MySQL user when you connect.

Because you didn't specify any user, it defaulted to an "anonymous" (unnamed) user. On Windows, the username is set to "ODBC" for some reason unknown to me.

Read this page (part of the tutorial) about connecting to the server.

And read the section of the docs starting at the link below, to learn more than you ever thought possible about users and privileges.

like image 104
Ashwin A Avatar answered Oct 23 '22 10:10

Ashwin A


I got the same issue and find my solution.

Go to path MySQL/data. Under this folder check for (.err) ERR file. There may be temporary password generated as below.

[Note] A temporary password is generated for root@localhost: _yJU=h0P!E<0

Hope it helps some one.

like image 39
user1302474 Avatar answered Oct 23 '22 09:10

user1302474


I was able to create a database, Grant permissions and flush privileges to activate the new permissions in a batch file:

Start of MySQLrun.bat

    @echo off
    :: I had to use the root user because the user I created didn't have any authority 
    set user=root
    ::set user=MyUser
    :: When I first installed MySQL I set a password
    set password=MyPassword
    set host=localhost

    CD C:\Program Files\MySQL\MySQL Server 5.5\bin
    :: Create a database file
    :: The log will be in C:\Program Files\MySQL\MySQL Server 5.5\bin

    mysql  -h %host% -u %user% -p%password% < c:\Dnload\MySQLCommands.sql --tee=Run.log --comments --debug-info --verbose
    cmd

End of MySQLrun.bat

The bat file runs the commands in the MySQLCommands.sql file:

Start of MySQLCommands.sql

    drop database if exists MyDatabaseFileName;
    CREATE DATABASE MyDatabaseFileName;
    # An example of how to GRANT ALL privileges to a user 
    #grant all ON mydatabasefilename.* TO 'Myuser'@localhost identified by 'MyPassword';
    # GRANT INSERT, DELETE, UPDATE, SELECT ON databasename.* TO ‘username’@'localhost’   IDENTIFIED BY ‘password’;
    # To activate the new permissions, issue the following command:
    FLUSH PRIVILEGES;
    #  How to log in to a specific database on a MySQL server:
show grants for 'MyUser'@'localhost' 

End of MySQLCommands.sql

Please Note: All usernames, Database names and passwords are case sensitive.

There are many ways to create a database. This is just one of them.

like image 1
Docfxit Avatar answered Oct 23 '22 09:10

Docfxit