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 [email protected]:/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)
 

你可能感兴趣的:(adb,android)