![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MySQL
arkblue
充满劳绩,但人还诗意地栖居在,大地之上
展开
-
MySQL主键删除/添加
2修改数据库和表的字符集alter database maildb default character set utf8;//修改数据库的字符集alter table mailtable default character set utf8;//修改表的字符集如果您想要把表默认的字符集和所有字符列(CHAR, VARCHAR, TEXT)改为新的字符集,应使用如下语句:ALTER TABLE tb转载 2009-04-30 16:03:00 · 127011 阅读 · 3 评论 -
mysql binlog 复制
1 基本概念(1)2原创 2014-09-24 21:28:10 · 3211 阅读 · 0 评论 -
Variable 'log_slave_updates' is a read only variable 不重启修改mysql变量
执行复制的时候遇到的问题mysql> show variables like 'log_slave_updates';+-------------------+-------+| Variable_name | Value |+-------------------+-------+| log_slave_updates | OFF |+-----------------原创 2015-01-27 16:55:31 · 9137 阅读 · 1 评论 -
mysql binlog事件 Rotate Event和Stop
top_log_event/STOP_EVENTA Stop_log_event is written under these circumstances:A master writes the event to the binary log when it shuts downA slave writes the event to the relay log when it shut原创 2015-01-26 21:00:29 · 4626 阅读 · 0 评论 -
同一个事务内修改两次,第二次改回原状会不会产生binlog,改前改后相同会不会产生binlog
实验一1 修改前表内容mysql> select * from user;+----------------------------+------+------------+-------+-------+| gmt_create | name | gmt_modify | gmt_4 | gmt_3 |+-----------------------原创 2015-06-07 17:44:55 · 3476 阅读 · 0 评论 -
mysqlbinlog读取远程机器binlog
拿本机的mysql做测试语句:mysqlbinlog -uroot -proot -h127.0.0.1 -P3306 --read-from-remote-server mysql-bin.000001 --base64-output=decode-rows -v > 1-u 用户名-p 密码-h 远程mysql实例host- P 端口--read-f原创 2016-03-18 07:10:12 · 7660 阅读 · 0 评论 -
mysql 给表添加唯一约束、联合唯一约束,指定唯一约束的名字
表结构FIELD TYPE COLLATION NULL KEY DEFAULT Extra PRIVILEGES COMMENT------------- ------------ -------------- ------ ------ ------- ---------原创 2013-06-10 13:06:44 · 77950 阅读 · 2 评论 -
MySQL 查看约束,添加约束,删除约束 添加列,修改列,删除列
MySQL 查看约束,添加约束,删除约束 添加列,修改列,删除列查看表的字段信息:desc 表名;查看表的所有信息:show create table 表名;添加主键约束:alter table 表名 add constraint 主键 (形如:PK_表名) primary key 表名(主键字段);添加外键约束:alter table 从表 add constraint 外键转载 2016-03-20 12:51:35 · 4840 阅读 · 0 评论 -
尝试insert ignore into
对于主键冲突的时候,自动忽略当前要插入的记录。违反唯一性约束的时候,同样丢弃当前要插入的数据。可以用在数据同步的场景,这个场景数据源只有insert 的Action,如果数据源含有update就会失败,不能同步update的更新字段。这样做到最终一直和幂等。mysql> select * from test_table;+----+------+| id | kk |+----+原创 2016-03-22 16:26:24 · 6027 阅读 · 0 评论 -
Data truncation: Truncated incorrect DOUBLE value
update nb_order set biz_context = biz_context + "mailNo=550457371017;mailNoDate=1468036800000;" where user_id = 62916164 and id = 23666483Data truncation: Truncated incorrect DOUBLE value: ';c原创 2016-07-21 21:00:21 · 2423 阅读 · 0 评论 -
MySQL 为日期增加一个时间间隔
MySQL 为日期增加一个时间间隔:date_add()set @dt = now();select date_add(@dt, interval 1 day); - 加1天select date_add(@dt, interval 1 hour); -加1小时select date_add(@dt, interval 1 minute); - 加1分转载 2016-07-08 13:48:37 · 16242 阅读 · 0 评论 -
mysql explain type
只关注explain的type字段1 id是主键的场景explain select * from task_wait WHERE id = 18913352id select_type table type possible_keys key key_len ref原创 2016-08-15 16:44:10 · 606 阅读 · 0 评论 -
mysql 意向锁作用
①在mysql中有表锁,LOCK TABLE my_tabl_name READ; 用读锁锁表,会阻塞其他事务修改表数据。LOCK TABLE my_table_name WRITe; 用写锁锁表,会阻塞其他事务读和写。②Innodb引擎又支持行锁,行锁分为共享锁,一个事务对一行的共享只读锁。排它锁,一个事务对一行的排他读写锁。③这两中类转载 2016-12-27 14:17:40 · 11700 阅读 · 2 评论 -
MySQL 修改索引名称
http://www.codeweblog.com/mysql-%E4%BF%AE%E6%94%B9%E7%B4%A2%E5%BC%95%E5%90%8D%E7%A7%B0/对于MySQL 5.7及以上版本,可以执行以下命令:ALTER TABLE tbl_name RENAME INDEX old_index_name TO new_index_name对于MySQL转载 2017-05-17 20:49:49 · 18235 阅读 · 0 评论 -
FLUSH TABLES WITH READ LOCK
参考今天在解决数据库同步异常的时候用到了flush tables with read lock 这个命令,于是顺便就学习了下锁表的相关知识。 1.FLUSH TABLES WITH READ LOCK 这个命令是全局读锁定,执行了命令之后所有库所有表都被锁定只读。一般都是用在数据库联机备份,这个时候数据库的写操作将被阻塞,读操作顺利进行。 解转载 2014-05-28 21:46:37 · 18042 阅读 · 1 评论 -
log event entry exceeded max_allowed_packet
java.io.IOException: Received error packet: errno = 1236, sqlstate = HY000 errmsg = log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the start event position from原创 2014-07-16 10:42:04 · 2305 阅读 · 0 评论 -
聚簇索引、非聚簇索引、覆盖索引
1 聚簇索引:cluster index 其实数据存储结构,索引和记录内容b原创 2014-05-20 20:56:48 · 7436 阅读 · 0 评论 -
JDBC Statement设置逃逸字符
http://my.oschina.net/forrest420/blog/63539 JDBC Statement的逃逸字符开关设置 void setEscapeProcessing(boolean enable) throws SQLException Sets escape processing on or off. If转载 2012-07-09 19:18:12 · 1601 阅读 · 0 评论 -
msyql show processlist
如果登陆的用户拥有super权限,,就可以看到所有连接到mysql的连接的状态。mysql> show processlist ;+----------+---------+----------------------+------+-------------+-------+------------------------------------------------------原创 2012-09-14 11:15:03 · 946 阅读 · 0 评论 -
mysql binlog binlog_cache_size
数据库事务1 begin2 写binlog buffer3 commit4 返回到 client5 binlog buffer 刷盘6 binlog dump 数据以上6件事到底是什么顺序?Mysql有很多系统变量可以设置,系统变量设置不同,会导致系统运行状态的不同。因此mysql提供两组命令,分别查看系统设置和运行状态。 1、系统设置:转载 2012-09-13 19:29:21 · 7711 阅读 · 0 评论 -
jdbc 语句 mysql关键字
jdbc 的 sql语句遇到了关键字- TIME = 2013-05-29 03:10:36.0- SOURCEID = SUBWAY-M2M-TF-8- POSITION = 002228:0203272686#363623406.1369768236- VARIABLE:- SCHEMA = subway_p31- TABLE = lunabidsetting-原创 2013-05-29 13:22:19 · 2276 阅读 · 0 评论 -
查看mysql最早的binlog文件编号
1 查看mysql最早的binlog文件编号mysql> show binlog events limit 10;+------------------+-----+-------------+-----------+-------------+----------------------------------------------------------------------+|原创 2013-07-09 14:34:53 · 2442 阅读 · 0 评论 -
mysql case when update 更新顺序
首先认为,在同一个事务里更新多条记录,mysql执行顺序和binlog的生成顺序一致java代码中调用jdbc如下次序更新数据库,Tx.beginSQL1SQL2SQL3Tx.end那么生成的binlog还是SQL1、SQL2、SQL3执行顺序但是在含有case when update语句中,生成的binlog顺序和,不是按照语句中从左到右的顺序的 Co原创 2013-06-26 18:48:43 · 6787 阅读 · 0 评论 -
User perf_inventory already has more than 'max_user_connections' active connections
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User perf_inventory already has more than 'max_user_connections' active connections意思是这个用户已经达到最大的连接数,不能再连接获得更多连接。max_conne原创 2013-08-01 23:15:16 · 1950 阅读 · 0 评论 -
mysql 添加字段 修改字段为not null
添加一个字段ALTER TABLE jw_user_role ADD zk_env VARCHAR(16);修改字段为not null,还要把原来的类型也写出来ALTER TABLE jw_user_role MODIFY zk_env VARCHAR(16) NOT NULL;原创 2013-07-21 10:42:03 · 68488 阅读 · 0 评论 -
链接mysql密码错误的异常 Access denied for user
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at sun.reflect.NativeCo原创 2013-10-09 15:18:58 · 4967 阅读 · 1 评论 -
mysql dump binlog master状态
遇到个dump binlog延迟增加的问题,发现master上的dump线程状态多数时间是 Finished reading one binlog; switching to next binlog查问题要看系统IO,可能是dump程序太多,导致IO繁忙;dba反馈load 8,iowait和ioutil并不高;但是业务在跑定时任务,导致tps很高,tps高会导致dump 变慢原创 2013-11-06 11:50:46 · 11357 阅读 · 0 评论 -
mysqlbinlog: Character set '#45' is not a compiled character set and is not specified in the '/usr/s
执行mysqlbinlog 命令是遇到的异常。原创 2014-05-19 21:10:41 · 8530 阅读 · 1 评论 -
mysql replace into和 insert into ... on duplicate update 区别
参考了两篇文章 http://blog.csdn.net/mchdba/article/details/8647560原创 2014-05-20 13:29:00 · 967 阅读 · 0 评论 -
mysql redolog 和binlog区别
参考 http://hatemysql.com/tag/sync_binlog/原创 2014-05-22 00:32:07 · 5464 阅读 · 0 评论 -
一条 sql group by
查询一条记录出现的次数不等一SELECT order_id,count(1) from table_xxx WHERE user_id = 4398048279448 and type = 2 GROUP BY order_id HAVING count(1)原创 2017-07-31 22:15:41 · 722 阅读 · 0 评论