2015年7月7日-------------------------

1、truncate表会清空建表语句auto_increment的值;某个表的id即是主键也是自增,你能够选择插入随意id值,假设不从1開始插入。从3開始insert,再插入没有id的值时。自增值是4

2、查看每种引擎的索引大小。来优化数据库參数
SELECT  ENGINE,  
ROUND(SUM(data_length) /1024/1024, 1) AS "Data MB",  
ROUND(SUM(index_length)/1024/1024, 1) AS "Index MB",  
ROUND(SUM(data_length + index_length)/1024/1024, 1) AS "Total MB",  
COUNT(*) "Num Tables"  
FROM  INFORMATION_SCHEMA.TABLES  
WHERE  table_schema not in ("information_schema", "performance_schema")  
GROUP BY  ENGINE; 

3、使用prepare stmt from准备一个动态sql语句时。主要
(1)被准备的语句定义时必须是会话级的变量不能是local变量,须要加@进行定义。准备后的语句直到会话结束才会丢失。能够使用deallocate prepare stmt消除分配的语句
表名不确定,检查这个表最大id。从id+1開始插入10行数据
BEGIN
-- 在存储过程中,一般的sql中values能够是变量,可是表名、字段名不能是变量
declare v_xname varchar(20) default 'testincre1';
delete from test.testincre1 where id=1;
select ifnull(max(id),0)+1 into @incre from test.testincre1;
set @end=@incre+10;
repeat
 set @sql=concat('insert into test.',v_xname,' values(@incre,''yangsq'',now());');
 select @sql;
 prepare stmt from @sql;
 execute stmt;
 deallocate prepare stmt;
set @incre=@incre+1;
until @incre=@end end repeat;
END
4、sql_slave_skip_counter
Last_SQL_Error: Error 'Unknown table 'sakila.testrepldb'' on query. Default database: 'sakila'. Query: 'DROP TABLE `testrepldb` /* generated by server */'
mysql> start slave sql_thread; 报错:会重复运行引起错误的sql,可是io_thread仍然正常会接受
2015-07-08 10:42:25 12378 [Warning] Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
2015-07-08 10:42:25 12378 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000012' at position 4449, relay log './yaolansvr_slave01-relay-bin.000014' position: 283
2015-07-08 10:42:25 12378 [ERROR] Slave SQL: Error 'Unknown table 'sakila.testrepldb'' on query. Default database: 'sakila'. Query: 'DROP TABLE `testrepldb` /* generated by server */', Error_code: 1051
2015-07-08 10:42:25 12378 [Warning] Slave: Unknown table 'sakila.testrepldb' Error_code: 1051
2015-07-08 10:42:25 12378 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000012' position 4449

select @@sql_slave_skip_counter;
stop slave;--或者stop slave sql_thread
set global sql_slave_skip_counter=1;
start slave;

--log-error:
2015-07-08 10:53:30 12378 [Warning] Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
2015-07-08 10:53:30 12378 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000012' at position 4449, relay log './yaolansvr_slave01-relay-bin.000014' position: 283
2015-07-08 10:53:30 12378 [Note] 'SQL_SLAVE_SKIP_COUNTER=1' executed at relay_log_file='./yaolansvr_slave01-relay-bin.000014', relay_log_pos='283', master_log_name='mysql-bin.000012', master_log_pos='4449' and new position at relay_log_file='./yaolansvr_slave01-relay-bin.000014',
relay_log_pos='410', master_log_name='mysql-bin.000012', master_log_pos='4576' 

5、从 sqlserver 查询mysql 报错 从数据类型 dbtype_dbtimestamp 转化为 datetime 时出错
mysql某表datetime类型数据是0028-01-01 00:00:00。插入sqlserver datetime报错,sqlserver datime支持的日期类型范围是1753 年 1 月 1 日到 9999 年 12 月 31 日

6、replicate的相关參数比較
--replicate-do-table:没有like pattern的功能,多个表须要指定多次
--replicate-wild-do-table:用like pattern的功能Example: --replicate-wild-do-table=foo%.bar% replicates only updates that use a table where the database name starts with foo and the table name starts with bar

mysql开发之---每日一得01的更多相关文章

  1. Win7搭建nginx+php+mysql开发环境以及websocket聊天实例测试

    Win7搭建nginx+php+mysql开发环境以及websocket聊天实例测试一.下载相关安装包 1.下载nginx最新版本(nginx1.3.13版之后才支持websocket协议) 下载地址 ...

  2. 深入理解MySQL开发性能优化.pptx

    深入理解MySQL开发性能优化.pptx,依旧上传baidu pan http://pan.baidu.com/s/1jIwGslS,视频暂未出,培训完成后会更新.

  3. 【MySql】赶集网mysql开发36条军规

    [MySql]赶集网mysql开发36条军规 2012-05-14 14:02:33 分类: Linux   写在前面的话: 总是在灾难发生后,才想起容灾的重要性: 总是在吃过亏后,才记得曾经有人提醒 ...

  4. mysql开发中使用存储过程

    在mysql开发中使用存储过程的理由: 当希望在不同的应用程序或平台上执行相同的函数,或者封装特定功能时,存储过程是非常有用的 mysql 执行语句是要先编译,然后再执行的.这样如果查询并发大的时候. ...

  5. [转载] 根据多年经验整理的《互联网MySQL开发规范》

    原文: http://weibo.com/p/2304181380b3f180102vsg5 根据多年经验整理的<互联网MySQL开发规范> 写在前面:无规矩不成方圆.对于刚加入互联网的朋 ...

  6. [转发] 老叶观点:MySQL开发规范之我见

    原文: http://imysql.com/2015/07/23/something-important-about-mysql-design-reference.shtml 老叶观点:MySQL开发 ...

  7. express框架+jade+bootstrap+mysql开发用户注册登录项目

    完整的项目代码(github):https://github.com/suqinhui/express-demo express是基于Node.js平台的web应用开发框架,用express框架开发w ...

  8. MySQL开发指南

    数据库开发是数据库管理系统(DBMS)和数据库应用软件设计研发的总称,数据运维.参与数据库生产环境的问题优化和解决等方面的事宜. 1.关于MySQL数据库 2.搭建MySQL环境 3.入门常用SQL. ...

  9. 第一篇:Win10系统搭建Python+Django+Nginx+MySQL 开发环境详解(完美版)

    Win10+Python+Django+Nginx+MySQL 开发环境搭建详解 PaulTsao 说明:本文由作者原创,仅供内部参考学习与交流,转载引用请注明出处,用于商业目的请联系作者本人. Wi ...

随机推荐

  1. 【Codeforces 258D】 Count Good Substrings

    [题目链接] http://codeforces.com/contest/451/problem/D [算法] 合并后的字符串一定是形如"ababa","babab&qu ...

  2. B1734 [Usaco2005 feb]Aggressive cows 愤怒的牛 二分答案

    水题,20分钟AC,最大值最小,一看就是二分答案... 代码: Description Farmer John has built a <= N <= ,) stalls. The sta ...

  3. SwiftUI 官方教程(一)

    完整中文教程及代码请查看 https://github.com/WillieWangWei/SwiftUI-Tutorials   创建和组合 View 此部分将指引你构建一个发现和分享您喜爱地方的 ...

  4. FileCopy文件复制

    package cn.com.filecopy; import java.io.FileInputStream; import java.io.FileNotFoundException; impor ...

  5. Codeforces Round #198 (Div. 2)C,D题解

    接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...

  6. Hibernate中实体对象的状态

    实体对象的状态 这里的实体对象是指Hibernate的O/R映射关系中的域对象(即O/R中的O).实体对象的生命周期是指实体对象由产生到被GC回收的一段过程,实体对象的生命周期包括3种状态:自由状态( ...

  7. [Offer收割]编程练习赛35

    有歧义的号码 #include<stdio.h> #include<string.h> #include<stdlib.h> int cmp(const void ...

  8. 完美解决ios10及以上Safari无法禁止缩放的问题

    移动端web缩放有两种: 1.双击缩放: 2.双指手势缩放. 在iOS 10以前,iOS和Android都可以通过一行meta标签来禁止页面缩放 <meta content="widt ...

  9. C++调用matlab编程

    C++调用Matlab,实在是不得已的方法.原文链接: http://kylen314.blog.com/2012/12/11/matlab_for_cplusplus/  这是个很善良的博客,只出现 ...

  10. 杭电 1002 A + B Problem II【大数相加】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 解题思路:就是把大的数用数组存放起来,像小学的时候用竖式加法来算两个数相加那样算: 反思:思路很 ...