最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MySQL實現(xiàn)免密登錄的三種配置方式

 更新時間:2024年03月28日 11:12:43   作者:恒悅sunsite  
我們登錄MySQL的時候有時候會忘記root密碼,這時我們需要免密登錄,所以這篇文章給大家介紹了MySQL免密登錄的三種方式,文章通過是示例代碼給出了詳細的配置方案,需要的朋友可以參考下

一、示例環(huán)境版本說明

操作系統(tǒng)版本centos7.6

[wuhs@test1 mysql]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

mysql數(shù)據(jù)庫版本5.7.32

[wuhs@test1 mysql]$ mysql -V
mysql Ver 14.14 Distrib 5.7.32, for el7 (x86_64) using EditLine wrapper

二、MySQL免密登錄方式配置示例

1、通過設(shè)置client標簽,直接編輯/etc/my.cnf文件

編輯/etc/my.cnf文件,添加如下代碼

[wuhs@test1 mysql]$ cat /etc/my.cnf
[client]
user = root
password = 123456
port = 3306

配置完成后可以使用mysql命令直接登錄數(shù)據(jù)庫

[wuhs@test1 mysql]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.32-log MySQL Community Server (GPL)
<br>
Copyright ? 2000, 2020, Oracle and/or its affiliates. All rights reserved.
<br>
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
<br>
Type ‘help;' or ‘\h' for help. Type ‘\c' to clear the current input statement.
<br>
mysql>

此方式最大問題是明文存儲密碼,見配置文件各用戶可見,非常的不安全。

2、我們通過my.cnf來配置,設(shè)置到~/.my.cnf來配置免密碼

編輯~/.my.cnf文件,添加如下代碼

[wuhs@test1 mysql]$ cat ~/.my.cnf
[client]
user = root
password = 123456
port = 3306

修改my.cnf屬性

#chmod 600 ~/.my.cnf
[wuhs@test1 mysql]$ ll ~/.my.cnf
-rw-------. 1 wuhs wuhs 51 Dec 29 22:56 /home/wuhs/.my.cnf

配置完成后可以使用mysql命令直接登錄數(shù)據(jù)庫

[wuhs@test1 mysql]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.32-log MySQL Community Server (GPL)
<br>
Copyright ? 2000, 2020, Oracle and/or its affiliates. All rights reserved.
<br>
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
<br>
Type ‘help;' or ‘\h' for help. Type ‘\c' to clear the current input statement.
<br>
mysql>

此種方式也是明文存儲,配置方式同第一種,文件為隱藏文件,設(shè)置文件為改用戶可讀,與第一種方式相比安全性有所提高。經(jīng)驗證測試,~/.my.cnf配置文件優(yōu)先于/etc/my.cnf。

3、通過mysql_config_editor命令

使用mysql_config_editor命令一個test標簽

[wuhs@test1 mysql]$ mysql_config_editor set -G test -S /tmp/mysql.sock -uroot -p
Enter password: [此處輸入root賬戶密碼]

執(zhí)行如上步驟后生成了隱藏文件.mylogin.cnf,文件類型為data,是一個二進制文件

[wuhs@test1 mysql]$ file ~/.mylogin.cnf
/home/wuhs/.mylogin.cnf: data

查看該文件,密碼為加密存儲

[wuhs@test1 mysql]$ mysql_config_editor print --all
[test]
user = root
password = *****
socket = /tmp/mysql.sock

使用mysql --login-path="標簽"登錄

[wuhs@test1 mysql]$ mysql --login-path=test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.32-log MySQL Community Server (GPL)
<br>
Copyright ? 2000, 2020, Oracle and/or its affiliates. All rights reserved.
<br>
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
<br>
Type ‘help;' or ‘\h' for help. Type ‘\c' to clear the current input statement.
<br>
mysql>

第三種方式登錄文件為隱藏的二進制文件,且密碼通過密文存儲,安全性最高。

以上就是MySQL免密登錄的三種方式的詳細內(nèi)容,更多關(guān)于MySQL免密登錄的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • mysql5.6.zip格式壓縮版安裝圖文教程

    mysql5.6.zip格式壓縮版安裝圖文教程

    這篇文章主要為大家詳細介紹了mysql5.6.zip格式壓縮版安裝圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • MySQL 重裝MySQL后, mysql服務(wù)無法啟動

    MySQL 重裝MySQL后, mysql服務(wù)無法啟動

    把mysql程序卸載后, 重裝, 結(jié)果mysql服務(wù)啟動不了,碰到這個問題的朋友可以參考下。
    2011-08-08
  • mysql 8.0.11 MSI版安裝配置圖文教程

    mysql 8.0.11 MSI版安裝配置圖文教程

    這篇文章主要為大家詳細介紹了mysql 8.0.11 MSI版安裝配置圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-09-09
  • mysql如何利用Navicat導(dǎo)出和導(dǎo)入數(shù)據(jù)庫的方法

    mysql如何利用Navicat導(dǎo)出和導(dǎo)入數(shù)據(jù)庫的方法

    這篇文章主要介紹了mysql如何利用Navicat導(dǎo)出和導(dǎo)入數(shù)據(jù)庫的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-02-02
  • MySql Binlog的5種場景+實操步驟全解析

    MySql Binlog的5種場景+實操步驟全解析

    本文詳細介紹了5種解析MySQL Binlog的方法,包括基于位點、時間、GTID、指定數(shù)據(jù)庫和加密Binlog的解析,附帶完整命令與場景說明,適合新手上手,每種方法都有具體適用場景和實操步驟,感興趣的朋友跟隨小編一起看看吧
    2026-02-02
  • MySQL添加索引特點及優(yōu)化問題

    MySQL添加索引特點及優(yōu)化問題

    這篇文章主要介紹了MySQL添加索引特點及優(yōu)化問題,MySQL索引的建立對于MySQL的高效運行是很重要的,索引可以大大提高MySQL的檢索速度,感興趣的小伙伴可以參考一下
    2022-07-07
  • MySQL實現(xiàn)異步復(fù)制的示例

    MySQL實現(xiàn)異步復(fù)制的示例

    MySQL的復(fù)制就是將來自一個MySQL數(shù)據(jù)庫服務(wù)器(主庫)的數(shù)據(jù)復(fù)制到一個或多個MySQL數(shù)據(jù)庫服務(wù)器(從庫),本文主要介紹了MySQL實現(xiàn)異步復(fù)制的示例,感興趣的可以了解一下
    2024-09-09
  • mysql InnoDB建表時設(shè)定初始大小的方法

    mysql InnoDB建表時設(shè)定初始大小的方法

    這篇文章主要介紹了mysql InnoDB建表時設(shè)定初始大小的方法,需要大家到MYSQL后臺實際操作方可以看到效果
    2013-11-11
  • MySQL視圖(view)的基本用法及說明

    MySQL視圖(view)的基本用法及說明

    這篇文章主要介紹了MySQL視圖(view)的基本用法及說明,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • MySQL最新版8.1.0安裝配置教程(圖文)

    MySQL最新版8.1.0安裝配置教程(圖文)

    MySQL是一種廣泛使用的開源數(shù)據(jù)庫管理系統(tǒng),MySQL 8.0是最新版本,它具有更好的性能和安全性,本文主要介紹了MySQL最新版8.1.0安裝配置教程,感興趣的可以了解一下
    2023-09-09

最新評論

海宁市| 汉中市| 来凤县| 乌审旗| 墨江| 固镇县| 芒康县| 阿拉尔市| 泰来县| 招远市| 玉田县| 镇巴县| 城口县| 岐山县| 元江| 泊头市| 拜泉县| 利津县| 鄢陵县| 正宁县| 荃湾区| 白河县| 石阡县| 六枝特区| 长沙县| 英吉沙县| 开阳县| 信阳市| 翼城县| 神木县| 历史| 宝鸡市| 图木舒克市| 湛江市| 盘山县| 台山市| 阿图什市| 新干县| 迭部县| 花莲县| 宜兰市|