Skip to content

Instantly share code, notes, and snippets.

先说解决方式:
Windows TZ环境变量设置:
TZ=CST-8:00
以下为一些心得:
MySQL的system_time_zone读取错误的问题,会导致以下类似命令出现Warning:
show variables like '%time_zone%';
show variables like '%char%';
Note:举例说明以中国时间为主体
1.时区定义TZ
含义:CST代表时区的别名,后面的+8:00才是实际定义时区的;
# 下面两个其实代表同一个时区,只是时区别名不一样,区别在于这里的名字ABC是非标准的. 但其实CST本身也有很多国家在用,比如美国、中国。
TZ=CST-8:00
TZ=ABC-8:00
# 默认为+0,当然-0也没毛病, 可不写出来;其实对于TZ来讲这时候标准别名应该用UTC,ZZZ是随意的一个名字。
TZ=ZZZ
TZ=ZZZ+0
..\MySQL\MySQL Server 5.7\DATA\my.ini
------------这两个可以省略-------------------------
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
-----------just use this----------------------------
# system-time-zone could be set in OS ENVIRON [TZ=CST-8:00], if mysql failed to get from os by default.
# default-time-zone could be removed [SYSTEM by default] if system-time-zone is rightly getted by mysql.
@mildcore
mildcore / mysql_encoding.md
Created April 19, 2020 11:44
Verify that tables have utf8 set. Set connection charset. Check database settings.

https://stackoverflow.com/a/11013986

I would not suggest Richies answer, because you are screwing up the data inside the database. You would not fix your problem but try to "hide" it and not being able to perform essential database operations with the crapped data.

If you encounter this error either the data you are sending is not UTF-8 encoded, or your connection is not UTF-8. First, verify, that the data source (a file, ...) really is UTF-8.

Then, check your database connection, you should do this after connecting:

SET NAMES 'utf8'; SET CHARACTER SET utf8;

@mildcore
mildcore / PhotoBucket.md
Last active June 10, 2017 06:08
PhotoBucket

Photobucket是一个提供影像寄存、视频寄存、幻灯片制作与照片分享服务网站,于2003年由Alex Welch与Darren Crystal利用Trinity Ventures提供的资金创。Photobucket一般会用作个人相册,寄存网络论坛上显示的头像以及视频的远端存放空间。

@mildcore
mildcore / txt
Created June 8, 2017 04:45
Second Gist
This is a Text.
@mildcore
mildcore / first.md
Last active April 11, 2020 09:27
First Gist

This is my first gist.