ERROR 1142 (42000) at line 6688: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for t

[root@slave2 bak]# mysql -u root -p < 20161206112352.sql 
Warning: Using a password on the command line interface can be insecure.
ERROR 1142 (42000) at line 6688: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'
mysql> select table_schema,table_name from information_schema.tables where table_name='accounts';
+--------------------+------------+
| table_schema       | table_name |
+--------------------+------------+
| performance_schema | accounts   |
+--------------------+------------+
1 row in set (0.11 sec)
且查看该备份文件,也确实有备份该表的备份语句:

USE `performance_schema`;

--
-- Table structure for table `accounts`
--


DROP TABLE IF EXISTS `accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `accounts` (
  `USER` char(16) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `HOST` char(60) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `CURRENT_CONNECTIONS` bigint(20) NOT NULL,
  `TOTAL_CONNECTIONS` bigint(20) NOT NULL
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

……

--不知道为什么我在两台安装有5.6.33的机器上分别备份,其中一台机器会自动备份该库performance_schema,另一台机器却不会。奇怪。有人说是不合理的升级mysql版本导致。不清楚。

由于导入数据时报错ERROR 1142 (42000) at line 6688: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts',
所以备份文件中performance_schema.accounts后的数据都无法恢复回来。
可以把关于performance_schema的备份语句注释掉或者删除掉,然后再恢复即可。
也可以通过这种方式明确不备份系统自带的库:
mysql -uroot -p -e 'show databases;'|grep -E -v "Database|information_schema|mysql|test|performance_schema" |xargs mysqldump -uroot -p --databases > all.bak





你可能感兴趣的:(MySql,学习,MySql,报错集锦,MySql,备份恢复)