企業案例 Mysql誤刪除使用者表如何恢復

2022-06-17 13:54:08 字數 1590 閱讀 4472

mysql> delete from mysql.user where 1=1;

query ok, 5 rows affected (0.00 sec)

#刪除使用者以後還是可以登陸,但是不要重啟

1)停止資料庫
#抽根菸冷靜一下

[root@db02 scripts]# systemctl stop mysqld

2)跳過授權表和網路啟動
[root@db02 scripts]# mysqld_safe --skip-grant-tables --skip-networking &
3)插入新的使用者
insert into mysql.user values ('localhost','root',password('123'),

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'y',

'','',

'','',0,0,0,0,'mysql_native_password','','n');

4)重啟啟動資料庫
[root@db02 scripts]# mysqladmin shutdown

200709 16:27:19 mysqld_safe mysqld from pid file /usr/local/mysql/data/db02.pid ended

[1]+ done mysqld_safe --skip-grant-tables --skip-networking

[root@db02 scripts]# systemctl start mysqld

1)停止資料庫
#抽根菸冷靜一下

[root@db02 scripts]# systemctl stop mysqld

2)跳過授權表和網路啟動
[root@db02 scripts]# mysqld_safe --skip-grant-tables --skip-networking &
3)授權乙個新使用者
mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

mysql> grant all on *.* to root@'localhost' identified by '123' with grant option;

query ok, 0 rows affected (0.00 sec)

mysql 誤刪除資料恢復

第一步 保證mysql已經開啟binlog 值必須為on 開啟binlog方法 第二步 檢視binlog存放日誌檔案目錄 第三步 檢視binlog row image 值必須為full 修改 binlog row image 第四步 檢視binlog模式 必須為行級模式row 修改模式方法 第五步 ...

mysql誤刪 mysql資料庫誤刪除後怎麼辦?

在日常運維工作中,對於資料庫的備份是至關重要的!資料庫對於 的重要性使得我們對 mysql 資料庫的管理不容有失!然而是人總難免會犯錯誤,說不定哪天大腦短路了,誤操作把資料庫給刪除了,怎麼辦?下面,就 mysql 資料庫誤刪除後的恢復方案進行說明。一 工作場景 mysql資料庫每晚12 00自動完全...

mysql 刪除回滾 Mysql資料誤刪除快速回滾

作者 video 極鏈科技opsteam 整理 包包 在資料庫操作中,難免會因為各種各樣的原因對資料造成損壞,這個時候就需要對資料庫快速恢復。傳統的方法會先恢復mysql備份,再去用mysqlbinlog抽取指定時間點的日誌,再恢復,這樣的操作比較耗時,容易出錯,那有沒有一種工具可以快速把誤刪除的操...