[英]mysql .my.cnf not reading credentials properly?
I can connect to mysql using the following line: 我可以使用以下行连接到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
Here is my .my.cnf in my home directory (not /etc/my.cnf): 这是我的主页目录中的.my.cnf(不是/etc/my.cnf):
[client]
user = myusername
password = mypassword
host = localhost
There also appears to be a client section in my /etc/my.cnf: 我的/etc/my.cnf中似乎还有一个客户端部分:
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
However when I just type "mysql" into the terminal, I get: 但是,当我在终端输入“mysql”时,我得到:
ERROR 1045 (28000): Access denied for user 'myusername'@'localhost' (using password: YES)
What is wrong with my my.cnf? 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) 此外,它与anon用户无关,如下所述: MySQL ERROR 1045(28000):拒绝访问用户'bill'@'localhost'(使用密码: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
As @Wrikken said in the comments, it will work if you quote your password and the password contains characters such as =
or ;
正如@Wrikken在评论中所说,如果您引用密码并且密码包含=
或;
等字符,它将起作用;
. 。
Your problem is that you are missing the quotes around the password. 您的问题是您错过了密码周围的引号。
[client]
user = myusername
password = "mypassword"
host = localhost
http://dev.mysql.com/doc/refman/5.7/en/option-files.html http://dev.mysql.com/doc/refman/5.7/en/option-files.html
Search for "Here is a typical user option file:" and see the example they state in there. 搜索“这是一个典型的用户选项文件:”并查看它们在那里说明的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.