国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

mysql密碼忘了怎么辦,如何修改mysql用戶密碼

2020-04-29 13:43:53
字體:
供稿:網(wǎng)友

 修改mysql用戶密碼的方法總結(jié)

  1.修改root密碼

  方法1:使用mysqladmin命令

  --適用于記得root舊密碼,修改root密碼

  語法:

  mysqladmin -u用戶名 -p舊密碼 password 新密碼

  例如:

  # mysqladmin -u root -proot password mysql

  --注意:如當(dāng)舊密碼輸入錯誤時會報如下錯誤

  # mysqladmin -u root -proot1 password mysql

  mysqladmin: connect to server at 'localhost' failed

  error: 'Access denied for user 'root'@'localhost' (using password: YES)'

  方法2:直接更新user表password字段

  --適用于忘記root密碼,而對root密碼進行重置

  

  Step 1: 修改MySQL的登錄設(shè)置

  # vi /etc/my.cnf

  --windows系統(tǒng)是my.ini文件

  --在[mysqld]的段中加上一句:skip-grant-tables,如沒有[mysqld]字段,可手動添加上

  [mysqld]

  datadir=/var/lib/mysql

  socket=/var/lib/mysql/mysql.sock

  skip-name-resolve

  skip-grant-tables

  Step 2: 重新啟動mysql

  [root@gc ~]# service mysql restart

  Shutting down MySQL..[確定]

  Starting MySQL...[確定]

  Step 3: 登錄并修改MySQL的root密碼

  --此時直接用mysql即可無需密碼即可進入數(shù)據(jù)庫了

  [root@gc ~]# mysql

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

  Your MySQL connection id is 2

  Server version: 5.5.24 MySQL Community Server (GPL)

  Copyright (c) 2000, 2011, 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> use mysql;

  Database changed

  mysql> update user set password=password('new_password') where user='root';

  Query OK, 5 rows affected (0.00 sec)

  Rows matched: 5  Changed: 5  Warnings: 0

  mysql> flush privileges;

  Query OK, 0 rows affected (0.00 sec)

  --注意:如果沒做step1,直接用mysql登錄時會報如下錯誤

  [root@gc ~]# mysql

  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

  Step 4: 將MySQL的登錄設(shè)置修改回來

  再刪除/etc/my.cnf文件中的skip-grant-tables

  Step 5: 重新啟動mysql

  [root@gc ~]# service mysql restart

  Shutting down MySQL..[確定]

  Starting MySQL...[確定]


(責(zé)任編輯:VEVB)

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 吉林省| 宁德市| 和顺县| 神农架林区| 溆浦县| 靖远县| 宜兰市| 榕江县| 天水市| 九龙县| 恭城| 伊吾县| 衡东县| 浮山县| 英吉沙县| 成武县| 富宁县| 屏东市| 颍上县| 高唐县| 田阳县| 大关县| 湛江市| 靖安县| 太原市| 通道| 玉门市| 米易县| 阿拉善右旗| 贵阳市| 新宁县| 墨江| 沈阳市| 永顺县| 扶绥县| 曲靖市| 博野县| 乾安县| 怀安县| 马公市| 年辖:市辖区|