3 回答

TA貢獻1802條經(jīng)驗 獲得超5個贊
如果您的MySQL客戶端/服務(wù)器版本是5.6.xa以避免警告消息的方式,請使用mysql_config_editor工具:
mysql_config_editor set --login-path=local --host=localhost --user=username --password
然后,您可以在shell腳本中使用:
mysql --login-path=local -e "statement"
代替:
mysql -u username -p pass -e "statement"

TA貢獻1813條經(jīng)驗 獲得超2個贊
我用類似的東西:
mysql --defaults-extra-file=/path/to/config.cnf
要么
mysqldump --defaults-extra-file=/path/to/config.cnf
config.cnf包含:
[client]
user = whatever
password = whatever
host = whatever
這使您可以擁有多個配置文件-用于不同的服務(wù)器/角色/數(shù)據(jù)庫。使用?/ .my.cnf僅允許您進行一組配置(盡管這可能是一組有用的默認值)。
如果您使用的是基于Debian的發(fā)行版,并且以root身份運行,則可以跳過上述內(nèi)容,而只需使用/etc/mysql/debian.cnf即可進入...:
mysql --defaults-extra-file=/etc/mysql/debian.cnf
添加回答
舉報