Linux別名設(shè)置導(dǎo)致mysql_config_editor配置登錄報錯
2022-10-17 22:40 瀟湘隱者 閱讀(231) 評論(0) 收藏 舉報接手一臺MySQL數(shù)據(jù)庫后,使用mysql_config_editor創(chuàng)建了一個--login-path=mydba后,但是登錄MySQL驗證測試時一直報“mysql: [ERROR] unknown variable 'login-path=mydba'”這個錯誤。
測試過程中發(fā)現(xiàn),使用絕對路徑時正常(測試成功),但是如果不使用絕對路徑的話, 就會報這個錯誤,如下所示:
使用相對路徑測試報錯:
$mysql --login-path=mydba
mysql: [ERROR] unknown variable 'login-path=mydba'
使用絕對路徑測試OK:
$ /app/mysql/bin/mysql --login-path=mydba
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1977670
Server version: 5.7.19-1-log Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
那么是什么原因?qū)е碌哪兀?最后經(jīng)過排查發(fā)現(xiàn)是因為 ~/.bashrc中設(shè)置了別名,從而導(dǎo)致這個錯誤出現(xiàn), 如下所示(截取部分內(nèi)容),原因:在shell的輸入mysql --login-path=mydba命令后,它會轉(zhuǎn)化成/app/mysql/bin/mysql -h localhost -u root -S /app/mysql/data/xxxx.sock -p --login-path=mydba ,這樣--login-path=mydba就不是第一個參數(shù)了。所以就會報錯。
$ more ~/.bashrc
# User specific aliases and functions
alias mysql='/app/mysql/bin/mysql -h localhost -u root -S /app/mysql/data/xxxx.sock -p'
取消別名后,問題解決。當(dāng)然也可以直接使用絕對路徑解決這個問題。所以如果你mysql_config_editor配置都正確的話,如果有一些很離奇的錯誤,不妨檢查一下別名(alias)等設(shè)置。
浙公網(wǎng)安備 33010602011771號