国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 临汾市| 邵阳市| 老河口市| 东兰县| 永宁县| 连云港市| 寻甸| 南靖县| 湖州市| 叶城县| 华容县| 信丰县| 麻栗坡县| 姚安县| 临城县| 纳雍县| 汨罗市| 仪征市| 彰武县| 莱西市| 中西区| 泌阳县| 康马县| 枣阳市| 西安市| 淄博市| 九江县| 桂平市| 松滋市| 连平县| 日土县| 买车| 梧州市| 苏州市| 闸北区| 房产| 望江县| 乌鲁木齐县| 济宁市| 青州市| 青州市|