Sql scripts
Sql scripts
按年/季/月/周/日/时统计
整体格式
SELECT DATE_FORMAT(FROM_UNIXTIME(created_at),'{FORMAT}') format, COUNT(*) cc FROM `user` GROUP BY format
{FORMAT}分类:
年:%Y
季:
DATE_FORMAT(FROM_UNIXTIME(created_at),'{FORMAT}') => CONCAT(DATE_FORMAT(FROM_UNIXTIME(created_at),'%Y'),FLOOR((DATE_FORMAT(FROM_UNIXTIME(created_at),'%m')+2)/3))
月:%Y%m
周:%Y%u
日:%Y%m%d
时:%Y-%m-%d %H
创建用户并授权
create user 'reader'@'%' identified by '***';
grant all on db_test.* to 'reader'@'%';
flush privileges;
创建utf8mb4字符集数据库
create database xxx default character set utf8mb4 collate utf8mb4_unicode_ci;
comments powered by Disqus