Published on

mysql 必知必会0

Authors
错误日志 Error: Field '字段名' doesn't have a default value

很明显这个错误是没有设置默认值,

错误日志 Error 1140: In aggregated query without GROUP BY, expression this is incompatible with sql_mode=only_full_group_by
  • 显示当前的sql_mode类型,去掉only_full_group_by类型,并设置指定类型,尝试插入一条数据
show variables like 'sql_mode%';   
select @@GLOBAL.sql_mode;
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';

SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

select company_name from t_company group by company_name;

SELECT id, type, status, name, is_default, is_erp_default, created_at, updated_at, deleted_at FROM `t_role`  WHERE `t_role`.`deleted_at` IS NULL AND ((`t_role`.`id` = 191)) ORDER BY `t_role`.`id` ASC LIMIT 1

INSERT  INTO `t_personal_news` (`company_user_id`,`company_type`,`news_title`,`news_content`,`status`,`news_type`,`news_url`,`user_type`,`created_at`,`updated_at`,`deleted_at`) VALUES ('141','0','融资申请提交成功','您的融资单申请已经提交成功,等待内部审核。','0','1','','1','2020-10-27 10:23:14.643076637 +0800 CST m=+5238.696629773','2020-10-27 10:23:14',NULL)

数据异常错误

docker-compose配置的映射目录没有知道到mysql数据中,导致一直没找到问题原因

错误配置
./mysql/my.cnf:/etc/mysql/my.cnf:ro
./mysql/data:/data'

正确配置
./mysql/my.cnf:/etc/mysql/my.cnf:ro
./mysql/data:/var/lib/mysql #指定mysql容器内部