在 Windows 7 上,我尝试通过命令行使用 mysql(通过 WAMP 安装),而无需明确指定我的用户名和密码,如下所示
shell> mysql
为此,我需要更改 MySQL 的配置文件,该文件应该是 my.ini。我就是这么做的
...
# The following options will be passed to all MySQL clients
[client]
password = my_password
port = 3306
socket = /tmp/mysql.sock
...
但是当我尝试访问 mysql 时,我仍然收到消息
ERROR 1045 (28000): Access denied for user 'ODBC'@localhost' (using password: NO)
我该如何解决这个问题?
我的 my.ini 位于
C:\wamp\bin\mysql\mysql5.5.24
请注意,上面指定的密码 my_password 不是我的真实密码,并且是在文件中指定的(不带引号)。
编辑:
好的,上面的方法有效 - 它允许我通过 CLI 使用 mysql - 但只有当我打开 WAMP 时...为什么?当它未打开时,我会像上面一样被拒绝访问...
最佳答案
它不是特别安全,但如果您将帐户名以及密码添加到 my.ini 文件中,它将为您工作
# The following options will be passed to all MySQL clients
[client]
user = "Fred"
password = "Bloggs"
port = 3306
socket = /tmp/mysql.sock
...
关于mysql - mysql 访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20674991/