国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

如何修改Linux服務器中的MySQL數據庫密碼

瀏覽:21日期:2023-09-05 20:31:47
目錄修改Linux服務器中的MySQL數據庫密碼1.知道mysql的密碼情況下2.不知道mysql的密碼情況下mysql5.7的密碼修改錯誤問題:ERROR 1054 (42S22): Unknown column 'password' in 'field list'的解決總結修改Linux服務器中的MySQL數據庫密碼1.知道mysql的密碼情況下

通過登錄mysql系統,

mysql -uroot -pEnter password: 【輸入原來的密碼】mysql>use mysql;

查看下自己mysql的版本,注意不同的版本修改密碼的方式會有所不同

mysql>select version();

根據自己的版本從下面的方式中,選擇一種進行修改密碼即可

5.7以前

mysql>update user set password=password(“123456”) where user=‘root';

5.7版本 user表沒有了password字段,要用authentication_string代替

mysql>update user set authentication_string=password(“123456”) where user=‘root';

8.0以上版本 注意密碼要有數字,大小寫字母,和特殊符號,要不密碼會驗證不通過

mysql>ALTER USER ‘root' IDENTIFIED BY ‘123456@Test';

刷新權限(必須步驟)

mysql> flush privileges;mysql> exit;

修改完后要記得重啟下mysql服務,讓修改生效

service mysqld restart2.不知道mysql的密碼情況下

不知道mysql密碼的情況下,在安全模式下啟動mysql,不用輸入密碼就可以登錄進去,&表示在后臺運行,不再后臺運行的話,就要再打開一個終端。

mysqld_safe --skip-grant-tables &

或者你可以

輸入:vi /etc/my.cnf 回車。在這個文件中的最后一行輸入:skip-grant-tables

然后重啟mysql服務 service mysqld restart 進入到安全模式,修改完密碼后記得再刪除掉這行數據重啟下

mysql -uroot -p

然后提示你輸入原密碼,安全模式下直接回車就可以進入mysql數據庫了;

mysql>use mysql;

后面的步驟跟上面一樣了,根據自己的版本選擇修改方式

5.7以前

mysql>update user set password=password(“123456”) where user=‘root';

5.7版本 user表沒有了password字段,要用authentication_string代替

mysql>update user set authentication_string=password(“123456”) where user=‘root';

8.0以上版本 注意密碼要有數字,大小寫字母,和特殊符號,要不密碼會驗證不通過

mysql>ALTER USER ‘root' IDENTIFIED BY ‘123456@Test';

刷新權限(必須步驟)

mysql> flush privileges;mysql> exit;

修改完后要記得重啟下mysql服務,讓修改生效

service mysqld restartmysql5.7的密碼修改錯誤問題:ERROR 1054 (42S22): Unknown column 'password' in 'field list'的解決

本意向修改一個用戶的密碼,網上搜到的命令為如下

mysql> update user set password=password(“新密碼”) where user=”用戶名”;

執行后報錯:

ERROR 1054(42S22) Unknown column 'password' in ‘field list’

錯誤的原因是 5.7版本下的mysql數據庫下已經沒有password這個字段了,password字段改成了authentication_string

所以請使用一下命令:

E:\app\mysql\mysql-5.7.22-winx64\bin>mysql -uroot -pmysql123 # 先進入數據庫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 8Server version: 5.7.22 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 itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql; # 使用mysqlDatabase changedmysql> select User from user; # 此處為查詢用戶命令+---------------+| User |+---------------+| root || root || mysql.session || mysql.sys || root |+---------------+5 rows in set (0.01 sec) mysql> update mysql.user set authentication_string=password('mysql') where user='root'; # 更新密碼Query OK, 3 rows affected, 1 warning (0.00 sec)Rows matched: 3 Changed: 3 Warnings: 1 mysql> flush privileges; # 數據刷新Query OK, 0 rows affected (0.00 sec) mysql> quit # 退出Bye E:\app\mysql\mysql-5.7.22-winx64\bin>mysql -uroot -pmysql # 再次進入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 9Server version: 5.7.22 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 itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

跟我這樣設置,就可以了,大家自己設置自己的密碼就行

總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: MySQL 數據庫
主站蜘蛛池模板: 国产精品美女一区二区 | 精品热线九九精品视频 | 久 在线播放 | 欧美在线一区二区三区精品 | 欧美黄成人免费网站大全 | 99视频精品在线 | 亚洲综合久久1区2区3区 | 色视频一区二区三区 | 欧美在线观看www | 久久精品国产99久久久 | 免费国产黄 | 国产成人在线小视频 | 性感美女视频免费网站午夜 | 久久青草免费线观最新 | 最新国产一区二区精品久久 | 亚洲欧美日韩国产vr在线观 | 久久六视频| 成人免费毛片网站 | 免费观看一级一片 | 乱人伦中文视频在线 | 日韩毛片大全免费高清 | 久青草国产在线 | 成人自拍网 | 亚洲视频在线看 | 欧美极品在线播放 | 色黄啪啪18周岁以下禁止观看 | 日本三级网站在线观看 | 亚洲高清在线看 | 真人一级毛片 | 国产国模福利视频 | 中文久草| 久久精品国产亚洲高清 | 一本大道香蕉大vr在线吗视频 | 色射网| 国产精品国产亚洲精品不卡 | 国产成人久久精品一区二区三区 | 欧美亚洲国产成人不卡 | 亚洲最大成人 | 中日韩欧美一级毛片 | 男人女人做刺激视频免费 | 四虎免费大片aⅴ入口 |