- 积分
- 793
- 金钱
- 668
- 威望
- 0
- 贡献
- 0
- HASS币
- 20
高级会员
- 积分
- 793
- 金钱
- 668
- HASS币
- 20
|
本帖最后由 honentan 于 2020-5-1 21:00 编辑
日志里面错误提示:
2020-04-25 12:26:26 ERROR (Recorder) [homeassistant.components.recorder] Error adding event: (MySQLdb._exceptions.OperationalError) (1366, "Incorrect string value: '\\xE5\\xA4\\xA97\\xE5\\xB0...' for column `hassdb`.`states`.`state` at row 1")
[SQL: INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: ('sensor', 'sensor.ztc1_time_d0bae463b90f', '39天7小时15分钟', '{"friendly_name": "\\u8fd0\\u884c\\u65f6\\u95f4", "icon": "mdi:gauge"}', 681, datetime.datetime(2020, 4, 25, 12, 26, 3, 869168, tzinfo=<UTC>), datetime.datetime(2020, 4, 25, 12, 26, 3, 869168, tzinfo=<UTC>), datetime.datetime(2020, 4, 25, 12, 26, 26, 235963), '5027a19204554a0abc7771594e76cd59', None)]
(Background on this error at: http://sqlalche.me/e/e3q8)
很明显,states表的state字段不能插入UTF8中文。
解决方法可以用alter table语句修改state字段的编码字符集。
如果库里面没有重要数据,更简单彻底的方法是:删除ha的数据库,比如hassdb,修改db默认属性,然后重新建库。
世界清净了!
忘了贴修改方法:
vi /opt/etc/mysql/my.cnf # 修改配置,通过omv-extra安装mysql,则默认配置文件/etc/mysql/mariadb.conf.d/50-server.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
|
|