解決MySQL去除密碼登錄告警的問題
背景
MySQL在命令行輸入密碼時會提示mysql: [Warning] Using a password on the command line interface can be insecure.
,在某些時候會干擾取值。
解決方法:
使用mysql_config_editor
可以解決這一問題。
login-path是從MySQL5.6開始支持的特性,借助mysql_config_editor
工具可以將登陸MySQL的認(rèn)證信息加密存放在.mylogin.cnf
文件。之后,MySQL客戶端可以通過讀取該加密信息進(jìn)行登陸。
示例:
[root@localhost mysql]# mysql_config_editor set --login-path=db_admin --host=192.168.1.6 --user=root --password Enter password: # 輸入密碼
參數(shù)
–login-path=name 登陸信息名稱 –host=name 登陸地址 –password 在登陸文件中添加密碼(該密碼會被mysql_config_editor自動加密) –user 用戶名 –port=name 端口 –socket=name sock文件
查看
# 顯示指定名稱的登陸信息 mysql_config_editor print --login-path=test # 顯示所有登陸信息 mysql_config_editor print --all
示例:
[root@localhost mysql]# mysql_config_editor print --all [db_admin] user = root password = ***** host = 192.168.1.6 [root@localhost mysql]# mysql_config_editor print --login-path=db_admin [db_admin] user = root password = ***** host = 192.168.1.6
刪除配置
mysql_config_editor remove --login-path=test
登陸
root@localhost mysql]# mysql --login-path=db_admin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10222 Server version: 5.7.37-log MySQL Community Server (GPL) Copyright (c) 2000, 2022, Oracle and/or its affiliates. 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>
到此這篇關(guān)于MySQL去除密碼登錄告警的文章就介紹到這了,更多相關(guān)MySQL密碼登錄告警內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
MySQL復(fù)合查詢操作實(shí)戰(zhàn)案例
這篇文章主要給大家介紹了關(guān)于MySQL復(fù)合查詢操作的相關(guān)資料,MySQL復(fù)合查詢是指在一個SQL語句中使用多個查詢條件,以過濾和檢索數(shù)據(jù),需要的朋友可以參考下2023-08-08mysql group_concat()函數(shù)用法總結(jié)
這篇文章主要介紹了mysql group_concat()函數(shù)用法,結(jié)合實(shí)例形式較為詳細(xì)的group_concat()函數(shù)的功能、使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-06-06MYSQL事務(wù)教程之Yii2.0商戶提現(xiàn)功能
這篇文章主要給大家介紹了關(guān)于MYSQL事務(wù)教程之Yii2.0商戶提現(xiàn)功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07MySQL運(yùn)維實(shí)戰(zhàn)使用RPM進(jìn)行安裝部署
這篇文章主要為大家介紹了MySQL運(yùn)維實(shí)戰(zhàn)使用RPM進(jìn)行安裝部署實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12MySQL用命令行運(yùn)行sql文件的詳細(xì)圖文教程
最近重新踩了一下mysql 這邊的坑,記錄一下自己忽略的地方,下面這篇文章主要給大家介紹了關(guān)于MySQL用命令行運(yùn)行sql文件的詳細(xì)圖文教程,文中通過實(shí)例代碼的非常詳細(xì),需要的朋友可以參考下2023-01-01