问题
On Windows 7, I am trying to use mysql (installed through WAMP) through the command line without explicitly specifying my username and password, like below
shell> mysql
To do that, I need to change the configuration file for MySQL, which is supposedly my.ini. I did just that
...
# The following options will be passed to all MySQL clients
[client]
password = my_password
port = 3306
socket = /tmp/mysql.sock
...
Yet when I try to access mysql, I still get the message
ERROR 1045 (28000): Access denied for user 'ODBC'@localhost' (using password: NO)
How can I fix this?
My my.ini is in
C:\wamp\bin\mysql\mysql5.5.24
Note that the password specified above, my_password, is not my real password and was specified in the file without quotations.
EDIT:
Okay, the above approach works - it allowed me to use mysql through the CLI - but only when I have WAMP on... Why? When it's not on, I get denied access like above...
回答1:
Its not particularly secure but if you add the account name to the my.ini file as well as the password it will work for you
# The following options will be passed to all MySQL clients
[client]
user = "Fred"
password = "Bloggs"
port = 3306
socket = /tmp/mysql.sock
...
来源:https://stackoverflow.com/questions/20674991/access-denied-to-mysql