• mysql只copy数据库文件而不copy系统表文件到另一个数据库,新库可以正常使用该库和表吗?


    猜测是不可以的,因为系统表存储的是表信息,备库系统表中没有该表信息是无法使用的,测试结果也证明了这一点。

    源库10.153.88.5:创建数据库和表
    mysql> create database test_qianyi;
    Query OK, 1 row affected (0.00 sec)

    mysql> use test_qianyi; 
    Database changed
    mysql> create table test1(ind int);
    Query OK, 0 rows affected (0.02 sec)

    mysql> insert into test1 values(12);
    Query OK, 1 row affected (0.00 sec)

    cd /testdata/mysql
    tar zcf test_qianyi.tar.gz test_qianyi
    scp test_qianyi.tar.gz mysql@10.153.88.6:/testdata/mysql


    迁移库到10.153.88.6
    [mysql@t3-dtpoc-dtpoc-web05 mysql]$ tar -xvf test_qianyi.tar.gz
    test_qianyi/
    test_qianyi/db.opt
    test_qianyi/test1.frm
    test_qianyi/test1.ibd

    [root@localhost:(none)]>use test_qianyi;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed

     

    10.153.88.6可以Use database,也可以show tables in database;但无法查询表,因为系统表 information_schema.TABLES中无该表信息

    [root@localhost:test_qianyi]>select * from test1;
    ERROR 1146 (42S02): Table 'test_qianyi.test1' doesn't exist
    [root@localhost:test_qianyi]>select * from test_qianyi.test1;
    ERROR 1146 (42S02): Table 'test_qianyi.test1' doesn't exist

    [root@localhost:test_qianyi]>show tables in test_qianyi;
    +-----------------------+
    | Tables_in_test_qianyi |
    +-----------------------+
    | test1                 |
    +-----------------------+
    1 row in set (0.00 sec)

    [root@localhost:test_qianyi]>select * from information_schema.TABLES where TABLE_SCHEMA='test_qianyi';
    Empty set (0.01 sec)


    而在10.153.88.5;

    mysql> select * from test1;
    +------+
    | ind  |
    +------+
    |   12 |
    +------+
    1 row in set (0.00 sec)

    mysql> select * from test_qianyi.test1;
    +------+
    | ind  |
    +------+
    |   12 |
    +------+
    1 row in set (0.00 sec)

    mysql> select * from information_schema.TABLES where TABLE_SCHEMA='test_qianyi';
    +---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
    | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME         | UPDATE_TIME         | CHECK_TIME | TABLE_COLLATION    | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
    +---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
    | def           | test_qianyi  | test1      | BASE TABLE | InnoDB |      10 | Dynamic    |          1 |          16384 |       16384 |               0 |            0 |         0 |           NULL | 2023-09-18 11:21:41 | 2023-09-18 11:21:51 | NULL       | utf8mb4_general_ci |     NULL |                |               |
    +---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
    1 row in set (0.00 sec)
     

  • 相关阅读:
    计算机毕设 opencv python 深度学习垃圾图像分类系统
    Nginx高可用 - Keepalived安装部署
    Netty网络框架学习笔记-16(心跳(heartbeat)服务源码分析)
    STC 51单片机54——气压水压计HX710B 串口显示均值滤波+滑窗滤波
    C++11智能指针学习笔记及拓展
    海智算法训练营第三十三天 | 第八章 贪心算法 part03 | ● 1005.K次取反后最大化的数组和 ● 134. 加油站● 135. 分发糖果
    季节优化算法(Seasons optimization algorithm,SOA)附matlab代码
    如何在响应头中防治xss
    PHP Session
    龙蜥降世,神龙升级,灵杰亮相,阿里云再出神器
  • 原文地址:https://blog.csdn.net/liys0811/article/details/132971390