【问题标题】:Mysql Time is stuck after export/import导出/导入后Mysql时间卡住
【发布时间】:2011-09-02 02:47:46
【问题描述】:

我的一个 mysql 用户以这种方式破坏了他的生产数据库:

他将所有数据导出到转储文件,然后删除所有内容,然后将数据重新导入数据库。 他从 Innodb 大表空间中保存了一些 Gig(我不知道他为什么这样做,但这不是重点)。

现在我们遇到了一个问题。

now()返回的时间总是一样的,操作的时间(不知道是导出时间还是导入时间)。

演示:

mysql> \! date
Wed May 25 22:49:24 CEST 2011
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2011-05-07 05:34:52 |    <--- the date of the export/import, mysql is stuck at this date
+---------------------+
1 row in set (0.00 sec)

mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2011-05-07 05:34:52 |
+---------------------+
1 row in set (0.01 sec)

mysql> show variables like 'timestamp';
+---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| timestamp     | 1304739292 |  <-- timestamp is stuck to this value
+---------------+------------+

mysql> set timestamp=1;        <-- i can manually change the time returned by now()
Query OK, 0 rows affected (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 1970-01-01 01:00:01 |
+---------------------+
1 row in set (0.00 sec)

mysql> select sysdate();
+---------------------+
| sysdate()           |
+---------------------+
| 2011-05-07 05:34:52 |   <--- but sysdate() is still stuck
+---------------------+
1 row in set (0.00 sec)

知道如何在不重新启动 mysqld 或重新导入数据的情况下解决此问题吗?

【问题讨论】:

  • MySQL 的错误日志是什么?
  • 我的错,日志被禁用了。
  • 您是否设置了 --sysdate-is-now 选项以使 SYSDATE() 返回与 NOW() 相同的值?这将有助于解决根本问题

标签: mysql time timestamp


【解决方案1】:

在这里大胆猜测: 如果在 mysql 中设置了“--sysdate-is-now”选项,则 SYSDATE() 的行为类似于 NOW() - 因此您不会看到上述两个函数之间的任何区别。来自http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_sysdate

SYSDATE() 返回它执行的时间。这与 NOW() 的行为不同,后者返回一个常数时间,指示语句开始执行的时间。

最终您的导入过程由于某种原因没有完成?使用“SHOW PROCESSLIST”检查进程列表,然后执行“KILL (Process_Id)”,看看这是否有助于让您的时间功能回到正轨。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2019-03-27
    • 2012-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多