• AutoMySQLBackup 3.0的一个小Bug


     

       使用AutoMySQLBackup 3.0做逻辑备份时,测试验证时发现AutoMySQLBackup使用mysqldump导出的数据库备份有问题,如下测试所示:

    $ ls
    daily  fullschema  latest  monthly  status  tmp  weekly
    $ cd daily/
    $ ls
    kkkk  mysql  performance_schema  sys
    $ cd kkkk/
    $ ls
    daily_kkkk_2021-09-22_16h45m_Wednesday.sql.gz
    $ gunzip daily_kkkk_2021-09-22_16h45m_Wednesday.sql.gz
    $ more daily_kkkk_2021-09-22_16h45m_Wednesday.sql
    -- MySQL dump 10.13  Distrib 5.7.34, for Linux (x86_64)
    --
    -- Host: 127.0.0.1    Database: kkkk
    -- ------------------------------------------------------
    -- Server version       5.7.34-log
     
     
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
     
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
     
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
     
    /*!40101 SET NAMES utf8 */;
     
    /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
     
    /*!40103 SET TIME_ZONE='+00:00' */;
     
    /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
     
    /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
     
    /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
     
    /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
     
    /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
     
     
    /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
     
    /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
     
    /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
     
    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
     
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
     
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
     
    /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
     
     
     
    -- Dump completed on 2021-09-22 16:45:39

     

    如上所示,测试发现没有导出对应数据库中的任何数据,经过测试和验证,最终发现是因为AutoMySQLBackup使用的数据库账号mybackup(参数CONFIG_mysql_dump_username指定的账号)的权限有问题。如下所示,此账号是Xtrabackup备份使用的一个账号,所以也用来做AutoMySQLBackup的账号使用,但是忘记设置相关权限了

     

    mysql> show grants for mybackup@'127.0.0.1';
    +------------------------------------------------------------------------------------------------------------------+
    | Grants for mybackup@127.0.0.1                                                                                    |
    +------------------------------------------------------------------------------------------------------------------+
    | GRANT RELOAD, PROCESS, SUPER, LOCK TABLES, REPLICATION CLIENT, CREATE TABLESPACE ON *.* TO 'mybackup'@'127.0.0.1'|
    | GRANT SELECT, INSERT ON `performance_schema`.* TO 'mybackup'@'127.0.0.1'                                         |
    +------------------------------------------------------------------------------------------------------------------+
    2 rows in set (0.00 sec)

    mysqldump是需要一些特定权限的,如下所示。

    GRANT SELECT, RELOAD, LOCK TABLES, REPLICATION CLIENT, SHOW VIEW, EVENT, TRIGGER  ON *.* TO 'mybackup'@'127.0.0.1';
     
    FLUSH PRIVILEGES;

     

    重新授予相关权限,重新测试验证,发现已经正常,如下所示。但是这种情况下,AutoMySQLBackup居然没有任何错误提示,而且也生成了对应的sql压缩文件。所以在使用过程中,千万要小心,一定要注意设置权限,测试验证备份文件是否正常。

     

    $ more daily_kkkk_2021-09-22_16h47m_Wednesday.sql
     
    -- MySQL dump 10.13  Distrib 5.7.34, for Linux (x86_64)
    --
    -- Host: 127.0.0.1    Database: kkkk
    -- ------------------------------------------------------
    -- Server version       5.7.34-log
     
     
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;
    /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
    /*!40103 SET TIME_ZONE='+00:00' */;
    /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
    /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
    /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
    /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
     
     
     
    --
    -- Table structure for table `test`
    --
     
     
    DROP TABLE IF EXISTS `test`;
    /*!40101 SET @saved_cs_client     = @@character_set_client */;
    /*!40101 SET character_set_client = utf8 */;
    CREATE TABLE `test` (
      `id` int(11) DEFAULT NULL,
      `name` varchar(12) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    /*!40101 SET character_set_client = @saved_cs_client */;
     
     
     
    --
    -- Dumping data for table `test`
    --
     
     
    LOCK TABLES `test` WRITE;
    /*!40000 ALTER TABLE `test` DISABLE KEYS */;
    INSERT INTO `test` VALUES (1,'kery'),(2,'kkk');
    /*!40000 ALTER TABLE `test` ENABLE KEYS */;
    UNLOCK TABLES;
    /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
     
     
     
    /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
    /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
    /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
    /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
     
     
     
    -- Dump completed on 2021-09-22 16:47:22
    扫描上面二维码关注我
    如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!
    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
  • 相关阅读:
    Circles and Pi
    必修3第三章概率mindmaps
    3.1.1随机事件的概率的Breamer(2018-03-22)
    2.0.4 CCLabelTTF在ios7下不显示的问题
    android BroadcastReceiver ACTION_TIME_TICK 系统时间监听不到
    继承自CCObject的对象成员变量出错或者为空的问题
    win7共享wifi
    vs2012相关配置
    cocosbuilder3.0使用小记
    vs2012 + cocos2d-x 2.1.5 + win7开发环境搭建步骤
  • 原文地址:https://www.cnblogs.com/kerrycode/p/15322090.html
Copyright © 2020-2023  润新知