1. Using Function
[root@oraclelinux6.localdomain][test]> select @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-24 23:41:50 |
+---------------------+
1 row in set (0.00 sec)
[root@oraclelinux6.localdomain][test]> create table test ( ts timestamp not null) ;
Query OK, 0 rows affected (0.01 sec)
[root@oraclelinux6.localdomain][test]> insert into test( ts) values (utc_timestamp());
Query OK, 1 row affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select * from test;
+---------------------+
| ts |
+---------------------+
| 2015-06-25 06:41:39 |
+---------------------+
1 row in set (0.00 sec)
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-24 23:41:50 |
+---------------------+
1 row in set (0.00 sec)
[root@oraclelinux6.localdomain][test]> create table test ( ts timestamp not null) ;
Query OK, 0 rows affected (0.01 sec)
[root@oraclelinux6.localdomain][test]> insert into test( ts) values (utc_timestamp());
Query OK, 1 row affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select * from test;
+---------------------+
| ts |
+---------------------+
| 2015-06-25 06:41:39 |
+---------------------+
1 row in set (0.00 sec)
2. Setting time_zone value
[root@oraclelinux6.localdomain][test]> select @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> set session time_zone='+00:00';
Query OK, 0 rows affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-25 06:44:20 |
+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> set session time_zone='SYSTEM';
Query OK, 0 rows affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-24 23:45:39 |
+---------------------+
1 row in set (0.00 sec)
[root@oraclelinux6.localdomain][test]> system date;
Wed Jun 24 23:45:47 PDT 2015
[root@oraclelinux6.localdomain][test]>
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> set session time_zone='+00:00';
Query OK, 0 rows affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-25 06:44:20 |
+---------------------+
1 row in set (0.01 sec)
[root@oraclelinux6.localdomain][test]> set session time_zone='SYSTEM';
Query OK, 0 rows affected (0.00 sec)
[root@oraclelinux6.localdomain][test]> select now();
+---------------------+
| now() |
+---------------------+
| 2015-06-24 23:45:39 |
+---------------------+
1 row in set (0.00 sec)
[root@oraclelinux6.localdomain][test]> system date;
Wed Jun 24 23:45:47 PDT 2015
[root@oraclelinux6.localdomain][test]>
3. Loading Named Time Zone table
You can use system's local's zoneinfo database. Or, You can use package that is available for download at the MySQL Developer Zone.
3.1 Using system's zoneinfo database.
shell> cd /db/mysql/bin
shell> ./mysql_tzinfo_to_sql /usr/share/zoneino >> /tmp/timezone.sql
shell> ./mysql -p -u root
[root@oraclelinux6.localdomain][]> source /tmp/timezone.sql
shell> ./mysql_tzinfo_to_sql /usr/share/zoneino >> /tmp/timezone.sql
shell> ./mysql -p -u root
[root@oraclelinux6.localdomain][]> source /tmp/timezone.sql
3.2 Using a package that is available for download at the MySQL Developer Zone.
You Can see a package file list this url.http://dev.mysql.com/downloads/timezones.html
Select one package for you. And then, Load MySQL's mysql schema.
[root@oraclelinux6.localdomain][]> use mysql;
[root@oraclelinux6.localdomain][mysql]> source /tmp/timezone_posix.sql
[root@oraclelinux6.localdomain][mysql]> source /tmp/timezone_posix.sql
댓글 없음:
댓글 쓰기