排障集锦:九九八十一难之第九难!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> source /opt/shang.sql;

问题描述二、 完全备份后无法进行数据恢复

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

解决方案

1、查看备份.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 */;

2、定位问题

回到数据库中 进入到绝对路径具体的库中 进行重新恢复

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)

猜你喜欢

转载自blog.csdn.net/weixin_47219935/article/details/108187709