通过 phpMyAdmin 按非字母顺序导出数据库表
我有一个来自 Joomla MultiSite 安装的 MySQL 数据库,其中有一组表,每个 Joomla 站点都有不同的前缀。当我通过 phpMyAdmin 导出数据库时,它会创建一个 SQL 文件,其中按字母顺序创建和填充表。问题在于,从属站点的表依赖于主站点的表,但按字母顺序,它们的前缀位于主站点之前。因此,导出工作正常,但当我尝试导入时,我会收到一个又一个错误,并且必须手动移动 SQL 文件中的部分以确保首先创建/填充依赖表。
那么,是否可以通过 phpMyAdmin 导出数据库,其中的表按特定顺序排列?
编辑:这是我收到的错误,应该澄清一些事情:
Error
SQL query: Documentation
--
-- Dumping data for table `j1_content_rating`
--
-- --------------------------------------------------------
--
-- Table structure for table `j1_core_acl_aro`
--
CREATE ALGORITHM = UNDEFINED DEFINER = `bookings_bpjms`@`localhost` SQL SECURITY DEFINER VIEW `bookings_bpjms`.`j1_core_acl_aro` AS SELECT `bookings_bpjms`.`js0_core_acl_aro`.`id` AS `id` , `bookings_bpjms`.`js0_core_acl_aro`.`section_value` AS `section_value` , `bookings_bpjms`.`js0_core_acl_aro`.`value` AS `value` , `bookings_bpjms`.`js0_core_acl_aro`.`order_value` AS `order_value` , `bookings_bpjms`.`js0_core_acl_aro`.`name` AS `name` , `bookings_bpjms`.`js0_core_acl_aro`.`hidden` AS `hidden`
FROM `bookings_bpjms`.`js0_core_acl_aro` ;
MySQL said: Documentation
#1146 - Table 'bookings_bpjms.js0_core_acl_aro' doesn't exist
导入脚本的 js0_ 部分位于 j1_ 部分之后,因此会发生此错误。如果我在文本编辑器中编辑此文件(30+ 兆并且每天都在增长),我可以找到 js0_ 部分并将它们移动到顶部,但这是乏味、耗时且容易出错的。
I have a MySQL database from a Joomla MultiSite installation where it has a set of tables with different prefixes for each Joomla site. When I export the db via phpMyAdmin it creates a SQL file where the tables are created and populated in alphabetical order. The problem is that the tables for the slave sites have dependencies on the tables for the master site, but alphabetically their prefixes are ahead of the master site. So the export works fine but when I try importing I get error after error and have to manually move sections around in the SQL file to make sure that the dependent tables are created/populated first.
So, is it possible to export a db via phpMyAdmin with the tables in a specific order?
EDIT: Here's the error I'm getting which should clarify things:
Error
SQL query: Documentation
--
-- Dumping data for table `j1_content_rating`
--
-- --------------------------------------------------------
--
-- Table structure for table `j1_core_acl_aro`
--
CREATE ALGORITHM = UNDEFINED DEFINER = `bookings_bpjms`@`localhost` SQL SECURITY DEFINER VIEW `bookings_bpjms`.`j1_core_acl_aro` AS SELECT `bookings_bpjms`.`js0_core_acl_aro`.`id` AS `id` , `bookings_bpjms`.`js0_core_acl_aro`.`section_value` AS `section_value` , `bookings_bpjms`.`js0_core_acl_aro`.`value` AS `value` , `bookings_bpjms`.`js0_core_acl_aro`.`order_value` AS `order_value` , `bookings_bpjms`.`js0_core_acl_aro`.`name` AS `name` , `bookings_bpjms`.`js0_core_acl_aro`.`hidden` AS `hidden`
FROM `bookings_bpjms`.`js0_core_acl_aro` ;
MySQL said: Documentation
#1146 - Table 'bookings_bpjms.js0_core_acl_aro' doesn't exist
The js0_ portions of the import script come after the j1_ portions, and so this error occurs. If I edit this file in a text editor (30+ megs and growing every day) I can find the js0_ portions and move them to the top, but this is tedious, time consuming and error prone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是外键检查(在这种情况下,文件开头的
SET FOREIGN_KEY_CHECKS=0
应该起作用),还是问题只是在实时环境中导入?使用 mysqldump ,表似乎按照您给出的顺序转储(如果您指定表而不仅仅是数据库),但据我所知,这是未记录的行为,因此不应依赖之上。
Is the problem foreign key checks (in which case a
SET FOREIGN_KEY_CHECKS=0
at the start of the file should work), or is the problem simply importing in a live environment?With
mysqldump
it seems the tables are dumped in the order you give them in (if you specify tables instead of just a database), but this is undocumented behavior as far as I know and hence should not be relied upon.