【发布时间】:2013-10-10 15:48:33
【问题描述】:
我可以使用以下行连接到 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
【问题讨论】:
-
你确定你没有混合你的密码和主机配置吗?
-
这是我的主目录中的 .my.cnf 文件,而不是 /etc/my.cnf 中的文件。这东西应该在那个里面吗?
-
否,但如果您收到
'myusername'@'mypassword'之类的消息,则似乎您在host=之后输入了密码,并且可能在password=之后输入了您的主机。如果应该是'myusername'@'localhost'... -
抱歉,这只是我的问题中的一个错误
-
嗯,我想到了一个最后的猜测:如果你的密码中有
=和其他字符......你需要引用密码,这样做帮忙?
标签: mysql