随笔分类 - SQL
摘要:方式一: 导出 SELECT * FROM 数据库.表名 INTO OUTFILE '文件存放位置'; # [Err] 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute
阅读全文
摘要:1、登录主数据库,进行如下操作: # 创建账号 create user 账号@localhost identified by '密码'; # 账号赋权 grant replication slave on *.* to 账号@localhost with grant option; # 刷新权限 f
阅读全文
摘要:1、查看MySQL版本 SELECT VERSION();//5.7.26 2、查看是否开启日志功能 SHOW VARIABLES LIKE 'log_bin';//OFF(未开启),ON(开启) 3、查看MySQL的安装路径 SHOW VARIABLES LIKE 'basedir'; 4、在安装
阅读全文
摘要:报错原因:当使用union或union all时查询出的字段的排序规则不同。 解决方法: select column(列名) collate utf8_unicode_ci(排序规则)from table(表名) union/union all select column(列名) collate u
阅读全文
摘要:一条语句查询三种类型的总数量。 select count(case when type=0 then 1 else null end) t1,count(case when type=1 then 1 else null end) t2,count(case when type=2 then 1 e
阅读全文