Chương trình mysql_tzinfo_to_sql giúp nạp bảng múi giờ vào database mysql. Dùng trên hệ thống có zoneinfo database (tập file mô tả múi giờ). Ví dụ: Linux, FreeBSD, Solaris, macOS. Vị trí thường: /usr/share/zoneinfo (/usr/share/lib/zoneinfo trên Solaris).
Gọi mysql_tzinfo_to_sql
Nếu hệ thống không có zoneinfo database, có thể cài gói tải về. mysql_tzinfo_to_sql gọi được nhiều cách:
shell> mysql_tzinfo_to_sql tz_dir shell> mysql_tzinfo_to_sql tz_file tz_name shell> mysql_tzinfo_to_sql --leap tz_file
Cú pháp gọi đầu tiên: truyền đường dẫn thư mục zoneinfo cho mysql_tzinfo_to_sql. Output pipe cho chương trình mysql.
Ví dụ:
shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
mysql_tzinfo_to_sql đọc file múi giờ hệ thống, sinh câu lệnh SQL, mysql xử lý để nạp vào bảng múi giờ.
Cú pháp thứ hai: nạp đơn lẻ file múi giờ tz_file tương ứng tên múi giờ tz_name:
shell> mysql_tzinfo_to_sql tz_file tz_name | mysql -u root mysql
Nếu múi giờ cần tính giây nhuận (leap seconds), dùng cú pháp thứ ba. Khởi tạo thông tin giây nhuận. tz_file là tên file múi giờ:
shell> mysql_tzinfo_to_sql --leap tz_file | mysql -u root mysql
Sau chạy mysql_tzinfo_to_sql, khuyến nghị restart server để không dùng dữ liệu múi giờ cache cũ.