我可以使用以下行连接到 mysql:
mysql -u myusername -p
(enters password into terminal)
>>>Welcome to the MySQL monitor. Commands end with ; or \g.
>>>Your MySQL connection id is 51
>>>Server version: 5.6.10-log Source distribution
这是我的主目录中的 .my.cnf(不是 /etc/my.cnf):
[client]
user = myusername
password = mypassword
host = localhost
我的 /etc/my.cnf 中似乎还有一个客户端部分:
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
但是,当我在终端中输入“mysql”时,我得到:
ERROR 1045 (28000): Access denied for user 'myusername'@'localhost' (using password: YES)
我的 my.cnf 有什么问题?
此外,它与此处提到的匿名用户无关:MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
以下是建议查询的结果:
>>>mysql --print-defaults
>>>mysql would have been started with the following arguments:
>>>--port=3306 --socket=/tmp/mysql.sock --no-auto-rehash --user=myusername --password=mypassword --host=localhost