• 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)
     

  • 相关阅读:
    了解操作符的那些事(二)
    CryptoCTF easy
    java计算机毕业设计springboot+vue的在线课程教学网站 视频考试等功能 elementUI
    带你了解LINUX反弹Shell的各种姿势(超详细)
    力扣第18题 四数之和 c++双指针注释版。
    Linux 连接已经终止的线程 线程的分离 线程取消
    SQL Server 安装后,服务器再改名,造成名称不一致,查询并修改数据库服务器真实名称
    java中重载与重写
    Prometheus-PushGateway自定义监控项
    从事电力行业施工需要什么资质,电力工程资质有什么作用
  • 原文地址:https://blog.csdn.net/liys0811/article/details/132971390