mysql許可權的誤操作的恢複

來源:互聯網
上載者:User

標籤:identified

mysql許可權的誤操作的恢複

原因:由於誤操作,我把repl使用者授予了所有許可權,但刪除了資料庫中的其他使用者及許可權,因此repl使用者雖然具有操作所有資料庫的許可權,但沒有grant許可權,所以若想授予其他使用者權限,來管理資料庫,出現這種狀況就酷斃了,沒有授予許可權怎麽辦?

誤操作過程:

mysql >grant all on *.* to ‘repl‘@‘192.168.1.%‘ identified by ‘123456‘;

mysql> flush privileges;

授予完以後,我把其他的所有使用者全部都刪除了,再來查看此時的使用者

mysql> select host,user,password from mysql.user;
+--------------+------+-------------------------------------------+
| host         | user | password                                  |
+--------------+------+-------------------------------------------+
| 192.168.1.%  | repl | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+--------------+------+-------------------------------------------+

查看授予使用者的許可權會發現grant許可權為N

mysql> select * from mysql.user\G;

*************************** 2. row ***************************
                  Host: 192.168.1.%
                  User: repl
              Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: N
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              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:
      password_expired: N

我的做法:

mysql> update mysql.user set  Grant_priv=‘Y‘ where user=‘repl‘ and host=‘192.168.1.%‘;

mysql>\q

再次登入

mysql >flush privileges;

你會發現令人高興的現象,授予其它使用者權限竟然OK了

mysql> grant all on *.* to ‘test1‘@‘192.168.1.%‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


本文出自 “7240173” 部落格,請務必保留此出處http://wwdyl.blog.51cto.com/7240173/1640430

mysql許可權的誤操作的恢複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.