centos系统、php、mysql设置时区

centos

这个为准 时区改为北京时间

mv /etc/localtime /etc/localtime.bak
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

同步定时为修改后时区时间

/bin/systemctl restart crond.service
service rsyslog restart
tail -f /var/log/cron

命令行 timedatectl set-timezone America/Fortaleza
  vim ~/.profile  也输入同样命令

命令行 date 查看时间

php  配置文件/usr/local/php/etc/php.ini
[Date]下面
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/Fortaleza

mysql 配置文件/etc/my.cnf

[mysqld]下面
default-time_zone='-03:00'

如何修改CentOS服务器时间为北京时间

  1. CentOS系统,发现服务器时间与北京时间往往不一致,存在时差。
> date

1.可以执行tzselect命令按提示更换时区,依次选择5-Asia,9-China,1-Beijing Time。

选 Asia, CentOS里序号5,aliyunOS里序号4

选 China,序号一般是 9

选 Beijing 序号1

选 Yes 序号 1


You can make this change permanent for yourself by appending the line

  TZ='Asia/Shanghai'; export TZ

to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you

can use the /usr/bin/tzselect command in shell scripts:

Asia/Shanghai

后续步骤

1.将TZ='Asia/Shanghai'; export TZ这行添加到/etc/profile(所有用户生效)或者~/.bash_profile(当前用户生效)

2.退出重新登录即可,也可执行source /etc/profile或source ~/.bash_profile立即生效

3.这时候再执行date查看日期就可以发现时区改为北京时间啦。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值