CentOS 系統中,MySQL 時間同步問題通常是由于系統時間不一致導致的。為了解決這個問題,你可以采取以下步驟:
sudo yum install ntp
sudo systemctl start ntpd
sudo systemctl enable ntpd
sudo systemctl status ntpd
ntpdate 命令同步系統時間:sudo ntpdate pool.ntp.org
sudo systemctl restart mysqld
SELECT NOW();
此外,你還可以考慮使用 chrony 作為 NTP 服務,它提供了更精確的時間同步。要安裝和使用 chrony,請按照以下步驟操作:
chrony:sudo yum install chrony
chronyd 服務并設置為開機自啟:sudo systemctl start chronyd
sudo systemctl enable chronyd
chronyd 服務正在運行:sudo systemctl status chronyd
chronyc 命令同步系統時間:sudo chronyc sources
sudo systemctl restart mysqld
SELECT NOW();
通過以上步驟,你應該可以解決 CentOS 系統中 MySQL 時間同步的問題。