如何设置MySQL的时区?

admin 阅读:55 2024-05-25

如何设置mysql的时区?

要知道当前时间,我们可以使用 now() 函数和 SELECT 语句。查询是 如下 -

mysql> SELECT now();

执行上述查询后,我们将获得当前时间。以下是输出 -

+---------------------+
| now()               |
+---------------------+
| 2018-10-06 12:57:25 |
+---------------------+
1 row in set (0.02 sec)

To set the time zone, we can use the command SET. The syntax is 如下 -

mysql> SET time_zone = "Some value";

Now I am applying the above query to set the time zone. The query is 如下 -

mysql> SET time_zone = "+9:50";
Query OK, 0 rows affected (0.00 sec)

我们也可以借助 SET 命令进行全局设置 -

mysql> set global time_zone="+9:00";
Query OK, 0 rows affected (0.00 sec)
声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!