簡體   English   中英

mysql .my.cnf沒有正確閱讀憑證?

[英]mysql .my.cnf not reading credentials properly?

我可以使用以下行連接到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有什么問題?

此外,它與anon用戶無關,如下所述: MySQL ERROR 1045(28000):拒絕訪問用戶'bill'@'localhost'(使用密碼: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 

正如@Wrikken在評論中所說,如果您引用密碼並且密碼包含=;等字符,它將起作用;

您的問題是您錯過了密碼周圍的引號。

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

http://dev.mysql.com/doc/refman/5.7/en/option-files.html

搜索“這是一個典型的用戶選項文件:”並查看它們在那里說明的示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM