1. <nobr id="easjo"><address id="easjo"></address></nobr>

      <track id="easjo"><source id="easjo"></source></track>
      1. 
        

      2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
      3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>
          貴州做網站公司
          貴州做網站公司~專業!靠譜!
          10年網站模板開發經驗,熟悉國內外開源網站程序,包括DEDECMS,WordPress,ZBlog,Discuz! 等網站程序,可為您提供網站建設,網站克隆,仿站,網頁設計,網站制作,網站推廣優化等服務。我們專注高端營銷型網站,企業官網,集團官網,自適應網站,手機網站,網絡營銷,網站優化,網站服務器環境搭建以及托管運維等。為客戶提供一站式網站解決方案?。?!

          mysql 更改密碼 alter_MySQL修改賬號密碼方法大全「建議收藏」

          來源:互聯網轉載 時間:2023-12-14 11:44:08

          前言:

          在日常使用數據庫的過程中,難免會遇到需要修改賬號密碼的情景,比如密碼太簡單需要修改、密碼過期需要修改、忘記密碼需要修改等。本篇文章將會介紹需要修改密碼的場景及修改密碼的幾種方式。

          1.忘記 root 密碼

          忘記 root 密碼的場景還是比較常見的,特別是自己搭的測試環境經過好久沒用過時,很容易記不得當時設置的密碼。這個時候一般常用的方法是跳過權限驗證,然后更改 root 密碼,之后再啟用權限驗證。以 MySQL 5.7 版本為例簡單講下主要過程:

          首先修改配置文件,在[mysqld]部分加上一句:skip-grant-tables ,加上此參數的目的是跳過權限驗證。然后重啟數據庫,數據庫再次啟動后,我們就可以不用密碼直接登錄數據庫修改密碼了。# skip-grant-tables 模式下修改root密碼

          [root@host ~]# mysql

          Welcome to the MySQL monitor. Commands end with ; or \g.

          Your MySQL connection id is 16

          Server version: 5.7.23-log MySQL Community Server (GPL)

          Copyright (c) 2000, 2018, 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> update mysql.user set authentication_string = password (‘xxxxxx’) where user = ‘root’ and host = ‘localhost’;

          Query OK, 0 rows affected, 1 warning (0.00 sec)

          Rows matched: 1 Changed: 0 Warnings: 1

          mysql> flush privileges;

          Query OK, 0 rows affected (0.01 sec)

          修改完 root 密碼后,再次去除 skip-grant-tables 參數,然后重啟下數據庫即可。

          2.幾種修改密碼的方法

          除去忘記密碼,可能還有其他情景需要修改密碼,這時候就可以采取普通方式修改密碼了。還是以 MySQL 5.7 版本為例,介紹幾種常用的修改密碼的方法。

          使用 alter user 修改

          比如如果想更改 testuser 賬號的密碼,我們可以使用 root 賬號登錄,然后執行 alter user 命令更改 testuser 賬號的密碼。mysql> alter user ‘testuser’@’%’ identified by ‘Password1’;

          Query OK, 0 rows affected (0.01 sec)

          mysql> flush privileges;

          Query OK, 0 rows affected (0.00 sec)

          使用 SET PASSWORD 命令

          使用 SET PASSWORD 修改密碼命令格式為 SET PASSWORD FOR ‘username’@’host’ = PASSWORD(‘newpass’); 同樣是使用 root 賬號可修改其他賬號的密碼。mysql> SET PASSWORD FOR ‘testuser’@’%’ = PASSWORD(‘Password2’);

          Query OK, 0 rows affected, 1 warning (0.00 sec)

          mysql> flush privileges;

          Query OK, 0 rows affected (0.00 sec)

          使用 mysqladmin 修改密碼

          使用 mysqladmin 命令修改賬號密碼格式為 mysqladmin -u用戶名 -p舊密碼 password 新密碼[root@host ~]# mysqladmin -utestuser -pPassword2 password Password3

          mysqladmin: [Warning] Using a password on the command line interface can be insecure.

          Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

          [root@host ~]# mysql -utestuser -pPassword3

          mysql: [Warning] Using a password on the command line interface can be insecure.

          Welcome to the MySQL monitor. Commands end with ; or \g.

          Your MySQL connection id is 2388

          Server version: 5.7.23-log MySQL Community Server (GPL)

          Copyright (c) 2000, 2018, 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>

          直接 update user 表

          其實 MySQL 所以的賬號信息都存儲在 mysql.user 表里面,我們也可以直接通過 update user 表來修改密碼。# 5.7及之后版本

          mysql> update mysql.user set authentication_string = password (‘Password4’) where user = ‘testuser’ and host = ‘%’;

          Query OK, 1 row affected, 1 warning (0.06 sec)

          Rows matched: 1 Changed: 1 Warnings: 1

          mysql> flush privileges;

          Query OK, 0 rows affected (0.01 sec)

          # 5.6及之前版本

          update mysql.user set password=password(‘新密碼’) where user=’用戶名’ and host=’host’;

          3.設置 login-path 本地快捷登陸

          為了防止密碼暴露及忘記密碼,我們還可以設置 login-path 來實現在本地不輸密碼快捷登錄。

          login-path 是 MySQL 5.6 開始支持的新特性。通過借助 mysql_config_editor 工具將登陸 MySQL 服務的認證信息加密保存在 .mylogin.cnf 文件(默認位于用戶主目錄)。MySQL 客戶端工具可通過讀取該加密文件連接 MySQL ,實現快捷登錄。

          假設我們想配置 root 賬號在本地快捷登錄,可以這么做:# 執行回車后需要輸入一次root密碼

          [root@host ~]# mysql_config_editor set –login-path=root -uroot -hlocalhost -p -P3306

          Enter password:

          # 配置完成后可以使用login-path登錄

          [root@host ~]# mysql –login-path=root

          Welcome to the MySQL monitor. Commands end with ; or \g.

          Your MySQL connection id is 2919

          Server version: 5.7.23-log MySQL Community Server (GPL)

          Copyright (c) 2000, 2018, 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>

          總結:

          本篇文章主要介紹了修改數據庫賬號密碼的幾種方法,基本涵蓋了所有的場景。這里也提醒下各位,數據庫賬號最好限制ip段登錄,密碼盡量復雜些,最好能夠定期修改,特別是重要的環境不能有半點馬虎。年底了,安全才是王道。

          標簽:MySQL-

          網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...

          在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...

          在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...

          金泉廣場購物中心都有什么品牌?金泉廣場購物中心有很多品牌在賣格力空調、海爾空調、華為手機、小米手機、vivo手機、OPPO手機、蘋果手機、海信電視、海爾電視、小米電視、蔚來電動車、比亞迪電動車、大眾汽車、奧迪汽車、寶馬汽車、奔馳汽車。...

          沈陽農業大學招生章程與注意事項?楊農業大學2020年全日制普通本科招生簡章一、學校全稱沈陽農業大學二、學校地址遼寧省沈陽市沈河區東陵路120號第三,學校的類型公立高等教育機構四。辦學水平本科課程動詞(verb的縮寫)辦學形式全部時間的不及物動詞辦學的主要條件校園占地面積197.2萬平方米(約2957.4畝);平均教學行政用房面積17.2平方米;平均宿舍面積8.6平方米;生師比16.3;專任教師12...

          2021春晚特效史無前例,在世界上處于什么水平?中央電視臺春節聯歡晚會舞臺從開始取代傳統舞臺設備的那一天起,全自動機械結構、全智能視頻升降舞臺就達到了世界一流水平。與美國、法國的頂級舞臺設備相比,在軟件的使用上還有差距。然而,經過多年的探索和改進,硬件設備并不比國外差,甚至比國際上許多大型發電設施差。近年來,中央電視臺在利用原有舞蹈設施的基礎上,不斷融合現代視頻技術和3D影像技術。起初,它只是對播...

          TOP
          国产初高中生视频在线观看|亚洲一区中文|久久亚洲欧美国产精品|黄色网站入口免费进人
          1. <nobr id="easjo"><address id="easjo"></address></nobr>

              <track id="easjo"><source id="easjo"></source></track>
              1. 
                

              2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
              3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>