首页 > 解决方案 > PhpMyAdmin 表导出忽略时间戳列

问题描述

我最近注意到,在导出带有 TIMESTAMP 列的 MySQL 表时,在执行 Export 的 INSERT 语句部分时会忽略该列。可能是什么问题呢?下图:

生成的导出 CREATE TABLE 语句:

-- Table structure for table `req_status`
DROP TABLE IF EXISTS `req_status`;
CREATE TABLE `req_status` (
  `req_id` int(11) NOT NULL,
  `stat_id` int(11) NOT NULL,
  `change_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

生成的导出 INSERT 语句

--
-- Dumping data for table `req_status`
--

INSERT INTO `req_status` (`req_id`, `stat_id`) VALUES
(1, 5),
(2, 5);

标签: mysqllinuxapachephpmyadmin

解决方案


这在使用 MySQL >= 8.0.13 时被报告为一个错误。据说它已在 phpMyAdmin 5.0.1 中修复,但我正在使用该版本并且仍然有这个问题,所以我不太确定它是。

https://github.com/phpmyadmin/phpmyadmin/issues/15315

您可以改用 mysqldump:

mysqldump -h [hostname] -u [user] -p [database-name] [tables] > [path-to-dump-file]

推荐阅读