官方迁移教程地址:https://dev.mysql.com/doc/refman/8.0/en/innodb-moving-data-files-offline.html
官方对此操作的称呼:服务器离线时移动表空间文件
修改my.cnf(mac系统下)、my.ini(win系统下)配置文件
[mysqld]
datadir=/Volumes/mac-back/mysql/data #指定原来data文件的目录
innodb_directories="/usr/local/mysql-8.0.19-macos10.15-x86_64/data;/Volumes/mac-back/mysql/data/" #将新data与原来的data都写上,用";"号隔开
配置完成之后,重启服务器
此处碰到一个错误,以下是错误日志,意思是找不到“db_mblog”库的索引了,或者索引指向错误,我直接把“db_mblog”对应的data文件夹中的文件夹删了
2021-08-13T08:22:51.6NZ mysqld_safe Logging to '/Volumes/mac-back/mysql/data/MacBook-Pro.local.err'.
2021-08-13T08:22:51.6NZ mysqld_safe Starting mysqld daemon with databases from /Volumes/mac-back/mysql/data
2021-08-13T08:22:51.985637Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.19) starting as process 10287
2021-08-13T08:22:51.988082Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-08-13T08:22:51.988803Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /Volumes/mac-back/mysql/data/ is case insensitive
2021-08-13T08:22:52.053203Z 1 [Warning] [MY-012197] [InnoDB] Unable to open '/usr/local/mysql-8.0.19-macos10.15-x86_64/data/mysql.ibd'
2021-08-13T08:22:52.053481Z 1 [Warning] [MY-012197] [InnoDB] Unable to open '/usr/local/mysql-8.0.19-macos10.15-x86_64/data/undo_001'
2021-08-13T08:22:52.053689Z 1 [Warning] [MY-012197] [InnoDB] Unable to open '/usr/local/mysql-8.0.19-macos10.15-x86_64/data/undo_002'
2021-08-13T08:22:52.053995Z 1 [ERROR] [MY-012209] [InnoDB] Multiple files found for the same tablespace ID:
2021-08-13T08:22:52.054113Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 8 = ['db_mblog/mto_post.ibd', 'dzf/dzf_project_intention.ibd']
2021-08-13T08:22:52.054228Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 11 = ['db_mblog/mto_post_tag.ibd', 'dzf/dzf_user.ibd']
2021-08-13T08:22:52.054344Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 12 = ['db_mblog/mto_resource.ibd', 'dzf/dzf_banner.ibd']
2021-08-13T08:22:52.054466Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 15 = ['db_mblog/mto_user.ibd', 'dzf/dzf_project.ibd']
2021-08-13T08:22:52.054589Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 16 = ['db_mblog/mto_user_oauth.ibd', 'dzf/dzf_city.ibd']
2021-08-13T08:22:52.054716Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 19 = ['db_mblog/shiro_role_permission.ibd', 'dzf/dzf_project_details.ibd']
2021-08-13T08:22:52.054844Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 20 = ['db_mblog/shiro_user_role.ibd', 'dzf/dzf_model_introduce.ibd']
2021-08-13T08:22:52.055180Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Failed, retry may succeed.
2021-08-13T08:22:52.055328Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2021-08-13T08:22:52.055594Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-08-13T08:22:52.055852Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-08-13T08:22:52.056248Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.