排障集錦:九九八十一難之第九難!mysql備份恢復路上的小插曲

問題描述一 斷點恢復ERROR 1146 (42S02) at line 35: Table ‘shang.info’ doesn’t exist

[root@localhost opt]# mysqlbinlog --no-defaults --stop-datetime='2020-08-23 13:29:04' /usr/local/mysql/data/mysql-bin.000002 | mysql -uroot -p
Enter password: 
ERROR 1146 (42S02) at line 35: Table 'shang.info' doesn't exist

解決思路

斷點恢復以前進行徹底備份mysql

mysql> source /opt/shang.sql;

問題描述2、 徹底備份後沒法進行數據恢復

ERROR 1146 (42S02): Table ‘shang.shang’ doesn’t exist

[root@localhost opt]# mysql -uroot -pAbc123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.17-log Source distribution

Copyright (c) 2000, 2016, 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> source /opt/shang.sql;    '進行數據恢復'
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> select * from shang;     '一直報錯'
ERROR 1146 (42S02): Table 'shang.shang' doesn't exist

解決方案

一、查看備份.sql 具體以下

-- Table structure for table `info`    
--

DROP TABLE IF EXISTS `info`;    '首先判斷info表是否存在,若是存在的話才能接一下操做'
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `info` (
  `id` int(11) NOT NULL,
  `name` char(4) NOT NULL,
  `score` decimal(5,2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

二、定位問題

回到數據庫中 進入到絕對路徑具體的庫中 進行從新恢復sql

mysql> use shang;
Database changed
mysql> source /opt/shang.sql;
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
mysql> select * from info;
+----+------+-------+
| id | name | score |
+----+------+-------+
|  1 | zhen | 99.00 |
|  2 | qqqq | 88.00 |
|  3 | wwww | 77.00 |
+----+------+-------+
3 rows in set (0.00 sec)
相關文章
相關標籤/搜索