MySQL 用户 'ODBC'@'localhost' <使用密码:是> 的访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12083655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:34:30  来源:igfitidea点击:

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

mysql

提问by Docfxit

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

我收到一个错误: 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

我刚刚安装了 MySQL 5.5.27.2 我创建了一个名为 myuser 我在 XP Pro sp3 中工作的用户

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

请让我知道正确的命令行(我想我需要先授予权限)创建一个数据库文件。

回答by Ashwin A

Try running the mysql command with the following option:

尝试使用以下选项运行 mysql 命令:

C:> mysql -u root

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

这指定了连接时的“root”MySQL 用户。

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.

因为您没有指定任何用户,所以它默认为“匿名”(未命名)用户。在 Windows 上,由于某种我不知道的原因,用户名设置为“ODBC”。

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

阅读页面(本教程的一部分)有关连接到服务器。

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

并阅读从下面链接开始的文档部分,以了解比您想象的更多的关于用户和权限的信息。

回答by user1302474

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.

转到路径 MySQL/data。在此文件夹下检查 (.err) ERR 文件。可能会生成如下临时密码。

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

【注意】root@localhost 生成临时密码:_yJU=h0P!E<0

Hope it helps some one.

希望它可以帮助某人。

回答by Docfxit

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

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

MySQLrun.bat 结束

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

bat 文件运行 MySQLCommands.sql 文件中的命令:

Start of MySQLCommands.sql

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

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.

创建数据库的方法有很多种。这只是其中之一。

回答by jimeast

My case was a dumb mistake I typed mysql u -jim -p

我的情况是一个愚蠢的错误,我输入了mysql u -jim -p