91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

【MySQL】mysql root密碼忘記怎么辦?

發布時間:2020-04-01 14:38:21 來源:網絡 閱讀:220 作者:wx58ef453da77e7 欄目:MySQL數據庫

MySQL忘記密碼了怎么解決

筆者曾經有一次誤刪了mysqlroot用戶,怎么辦?

之前的解決方式是通過忽略授權表的方式重啟mysql然后插入相關數據解決該問題的,但是這種方式需要重啟mysql,會影響現有業務,那么有沒有其他方式可以不重啟MySQL就解決呢?

因為mysql的user表示MyISAM引擎的,因此我們可以通過修改對應的文件來解決這個問題。下面是本人在測試環境的一次演練,僅供參考。

一、查看現有用戶
04:18:34 root@localhost [mysql]>select user,host from user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+
3 rows in set (0,00 sec)
二、刪除本地root用戶
04:18:59 root@localhost [mysql]>drop user root@'localhost';
三、再次查看用戶
04:20:02 root@localhost [mysql]>select user,host from user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
+---------------+-----------+

現在我們開始恢復用戶數據

四、移動user表相關文件
[root@localhost mysql]# cp user.* /vagrant/mysql/3307/data/test/
五、登錄另一個實例并查看user表
04:23:53 root@localhost [(none)]>use test;
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
04:23:56 root@localhost [test]>show tables;
+----------------+
| Tables_in_test |
+----------------+
| user           |
+----------------+
1 row in set (0,00 sec)

04:23:58 root@localhost [test]>select * from user\G
*************************** 1. row ***************************
                  Host: localhost
                  User: mysql.session
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: Y
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              ssl_type:
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *C7A1AAE2D250AFD864050FAF4935EF6F5D185A92
      password_expired: N
 password_last_changed: 2018-02-23 13:19:12
     password_lifetime: NULL
        account_locked: Y
*************************** 2. row ***************************
                  Host: localhost
                  User: mysql.sys
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: N
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              ssl_type:
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *C7A1AAE2D250AFD864050FAF4935EF6F5D185A92
      password_expired: N
 password_last_changed: 2018-02-23 13:19:26
     password_lifetime: NULL
        account_locked: Y
2 rows in set (0,00 sec)
六、把本實例的root用戶插入剛剛移動過來的user表
04:25:03 root@localhost [test]>insert into user select * from mysql.user where user = 'root' and host ='localhost';
Query OK, 1 row affected (0,02 sec)
Records: 1  Duplicates: 0  Warnings: 0
七、再次移動user文件到原先的位置
[root@localhost test]# cp user.* /vagrant/mysql/3306/data/mysql
八、重新加載配置到內存
[root@localhost test]# kill -HUP `pidof mysqld`

通過該步mysql并不會重啟,對應用不會有影響

九、重新登錄,OK
[root@localhost test]# mysql -uroot -p -S /tmp/mysql3306.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.21-log MySQL Community Server (GPL)

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

04:30:57 root@localhost [(none)]>
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

连山| 新余市| 双桥区| 钟山县| 新竹市| 西乌珠穆沁旗| 宜昌市| 合作市| 射洪县| 永善县| 汕头市| 睢宁县| 滦南县| 谢通门县| 南昌县| 丘北县| 南澳县| 盐池县| 微山县| 阳江市| 临漳县| 通化县| 巴塘县| 普安县| 沛县| 金乡县| 张家川| 马龙县| 新竹县| 博野县| 交口县| 文安县| 和顺县| 德令哈市| 合作市| 义马市| 平度市| 长葛市| 余姚市| 宁河县| 云浮市|