mysql .my.cnf无法正确读取凭据? [英] mysql .my.cnf not reading credentials properly?

查看:102
本文介绍了mysql .my.cnf无法正确读取凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下行连接到mysql:

I can connect to mysql using the following line:

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

这是我的主目录(不是/etc/my.cnf)中的.my.cnf:

Here is my .my.cnf in my home directory (not /etc/my.cnf):

[client]
user = myusername
password = mypassword
host = localhost

在我的/etc/my.cnf文件中似乎也有一个客户端部分:

There also appears to be a client section in my /etc/my.cnf:

# The following options will be passed to all MySQL clients
[client]
#password   = your_password
port     = 3306
socket      = /tmp/mysql.sock

但是,只要在终端中输入"mysql",我就会得到:

However when I just type "mysql" into the terminal, I get:

ERROR 1045 (28000): Access denied for user 'myusername'@'localhost' (using password: YES)

我的my.cnf有什么问题?

What is wrong with my my.cnf?

此外,它与此处提到的匿名用户无关:

ALso, it has nothing to do with anon user as mentioned here: MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

以下是建议查询的结果:

Here is the result of a suggested query:

>>>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 

推荐答案

正如@Wrikken在评论中所说,如果您引用密码并且密码中包含诸如=;之类的字符,它将可以正常工作.

As @Wrikken said in the comments, it will work if you quote your password and the password contains characters such as = or ;.

这篇关于mysql .my.cnf无法正确读取凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆