MySQL 时区设置
作者: 我不是鱼 (2008-12-29 12:02)分类: MySQL 标签: 时区 time_zone
MySQL 时区默认是服务器的时区。
可以通过以下命令查看
SQL代码
- mysql> show variables like '%time_zone%';
-
+
- | Variable_name | Value |
-
+
- | system_time_zone | CST |
- | time_zone | SYSTEM |
-
+
-
2 rows in set (0.00 sec)
可以通过修改my.cnf
在 [mysqld] 之下加
default-time-zone=timezone
来修改时区。如:
default-time-zone = '+8:00'
改了记得重启msyql喔
注意一定要在 [mysqld] 之下加 ,否则会出现 unknown variable 'default-time-zone=+8:00'
另外也可以通过命令 set time_zone = timezone
比如北京时间(GMT+0800)
set time_zone = '+8:00';
这个和php的时区设置又有点差别,比如北京时间在php中是
date_default_timezone_set('Etc/GMT-8');
美国pst时间(GMT-08:00)
set time_zone = '-8:00';
SQL代码
- mysql> set time_zone = '+8:00';
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql> select now();
-
+
- | now() |
-
+
- | 2008-12-29 11:26:36 |
-
+
-
1 row in set (0.00 sec)
-
-
mysql> set time_zone = '-8:00';
-
Query OK, 0 rows affected (0.00 sec)
-
-
mysql> select now();
-
+
- | now() |
-
+
- | 2008-12-28 19:27:09 |
-
+
-
1 row in set (0.00 sec)
评论 (2) | 浏览 (4323)
前一篇: RSS2.0元素元素列表
后一篇: HTML 中的 meta
评论
[游客]gg 2009-01-05 22:47
[游客]fang 2010-07-27 18:23
1
Hakuna Matata
The Personal Blog of Vivek Gite
How Do I Restart MySQL Server?
by VIVEK GITE · 29 COMMENTS
Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).
First login as root user. Now type the following command as per your Linux distro:
A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:
* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
/etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start
# service mysqld stop
# service mysqld restart
(B) If you are using mysql on Debian / Ubuntu Linux then use following command:
* To start mysql server:
/etc/init.d/mysql start
* To stop mysql server:
/etc/init.d/mysql stop
* To restart mysql server
/etc/init.d/mysql restart
More MySQL articles are here and here.
Global site tag (gtag.js) - Google Analytics
{ 29 comments… read them below or add one }