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

首頁 > 數據庫 > MySQL > 正文

MySQL的root密碼忘記或丟失的解決方法一例

2024-07-24 12:31:25
字體:
來源:轉載
供稿:網友
      -bash-4.2$ service mysql status
     SUCCESS! MySQL running (2670)
     -bash-4.2$ mysql -u root -p
     Enter password:
     ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
 
      以下是密碼忘記的解決方法:
 
修改MySQL的參數設置:
# vi /etc/my.cnf
在[mysqld]的段最后一行加上一句:skip-grant-tables
例如:
[mysqld]
........................
log-bin=mysql-bin
innodb_data_file_path = ibdata1:12M;ibdata2:100M;ibdata3:300M:autoextend
innodb_file_per_table=on
max_connections=500
skip-grant-tables    --新增加行
保存并且退出vi.
 
重啟MySQL服務:
[root@chenfeng subsys]# service mysql restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!
 
-bash-4.2$ mysql    --不用輸密碼直接登錄
Welcome to the MariaDB monitor.  Commands end with ; or /g.
Your MySQL connection id is 2
Server version: 5.6.15-log Source distribution
  
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
  
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
  
MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| chenfeng           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)
  
MySQL [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
  
Database changed
MySQL [mysql]>  UPDATE user SET Password = password ('12345678') WHERE User ='root';   --修改為新密碼12345678
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
 
MySQL [mysql]>
MySQL [mysql]> flush privileges;   --刷新一下權限表
Query OK, 0 rows affected (0.00 sec)
 
MySQL [mysql]> quit
Bye
 
將MySQL的參數設置修改回來:
# vi /etc/my.cnf
將剛才在[mysqld]的段中最后一行加上的skip-grant-tables刪除,然后保存退出。
 
重啟MySQL服務:
[root@chenfeng subsys]# service mysql restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!
  
重新用新密碼登錄:
-bash-4.2$ mysql -u root -p12345678      --12345678為新密碼
Welcome to the MariaDB monitor.  Commands end with ; or /g.
Your MySQL connection id is 7
Server version: 5.6.15-log Source distribution
  
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
  
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
  
MySQL [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
  
Database changed
MySQL [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| chenfeng           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)
 
MySQL [mysql]> 

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扬中市| 桐梓县| 赤城县| 哈尔滨市| 清丰县| 噶尔县| 喀喇沁旗| 信阳市| 怀化市| 麻栗坡县| 鄂伦春自治旗| 涞水县| 阳高县| 简阳市| 余干县| 鄂托克前旗| 右玉县| 时尚| 瑞安市| 西和县| 秀山| 赣榆县| 德江县| 阳朔县| 康马县| 青川县| 福鼎市| 申扎县| 晋宁县| 田阳县| 余姚市| 淮阳县| 新竹市| 凭祥市| 太白县| 松桃| 白河县| 东城区| 江城| 承德县| 华容县|