MySQL
乐杨俊
编码的世界 Code Life!
展开
-
mysql Error 1055: Expression #1 of ORDER BY clause is not in GROUP BY ...
Error 1055: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'db.order.pay_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_grou原创 2023-01-30 09:53:48 · 320 阅读 · 0 评论 -
MySQL Lock wait timeout exceeded; try restarting transaction 锁等待
MySQL Lock wait timeout exceeded; try restarting transaction 锁等待原创 2022-07-26 16:31:26 · 495 阅读 · 0 评论 -
MySQL区分大小写
MySQL区分大小写目录1:MySQL表面区分大小写2:表字段内容区分大小写1:MySQL表名区分大小写可以通过:lower_case_table_names参数来设置一 :修改方式1:修改数据库参数文件:my.cnf2:在mysqld下 添加或修改 lower_case_table_names = 13:重启数据库二 :参数值含义lower_case_t原创 2022-03-08 16:15:17 · 7424 阅读 · 0 评论 -
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘temp.summa
目录1-MySQL执行SQL报错2-错位原因3-问题解决一:临时修改生效二:永久生效1-MySQL执行SQL报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'temp.summary_date' which is not functionally dependent on columns in GROUP BY clause; this is in原创 2021-09-08 19:46:02 · 105 阅读 · 0 评论 -
SQLSTATE[HY000]: General error: 8002 [93735529] can not retry select for update statement
MySQL|TIDB报错:SQLSTATE[HY000]: General error: 8002 [93735529] can not retry select for update statement原因:Error Number: 8002 带有 SELECT FOR UPDATE 语句的事务,在遇到写入冲突时,为保证一致性无法进行重试,事务将进行回滚并返回该错误。出现这种错误,应用程序可以安全地重新执行整个事务。...原创 2021-05-14 15:52:36 · 521 阅读 · 0 评论 -
MySQL内置函数详细介绍
MySQL内置函数 字符串函数: select concat("hello","word"); 链接字串 ->hello world lcase("MYSQL") 转换成小写 ucase("mysql") 转换成大写 length("leyangjun") string长度原创 2014-08-11 15:22:48 · 626 阅读 · 0 评论 -
MySQL Key值(PRI, UNI, MUL)的含义
PRI主键约束;UNI唯一约束;MUL可以重复原创 2014-08-26 18:13:39 · 6532 阅读 · 0 评论 -
Mysql主键索引、唯一索引、普通索引、全文索引、组合索引的区别
Mysql主键索引、唯一索引、普通索引、全文索引、组合索引的区别原创 2015-01-06 17:26:39 · 14823 阅读 · 0 评论 -
Mysql 查询缓存
Mysql 查询缓存原创 2015-04-03 15:17:23 · 556 阅读 · 0 评论 -
MySQL普通索引、唯一索引、主索引、外键索引、复合索引、全文索引的使用
MySQL普通索引、唯一索引、主索引、外键索引、复合索引、全文索引的使用原创 2015-05-20 12:49:44 · 4363 阅读 · 0 评论 -
Myisam表锁
Myisam表锁 一:myisam读锁定(所有人只有读权限不能进行增删改) 1:lock table t1 read 2:开启另一个MySQL链接端,接着去尝试:select * from t1; 3: 再insert、update 和 delete t1这张表,你会发现所有的执行的sql都停留在终端上没有真正的去操作执行,直到解锁为止自动就执行 4:读锁定对我们在多备原创 2014-08-11 15:21:15 · 813 阅读 · 0 评论 -
show table status like 'table'\G 详细信息介绍
show table status like 'table'\G 表整体对于字段值详细信息介绍原创 2015-05-30 15:53:48 · 2388 阅读 · 0 评论 -
MySQL延迟更新索引(delay_key_write)
MySQL延迟更新索引(delay_key_write)原创 2015-05-30 16:48:12 · 3033 阅读 · 0 评论 -
MySQL视图
MySQL视图 定义:视图是一个虚拟表,其内容由查询定义,是根据建立视图的sql语句拿到的数据保存在一张表中而创建的表-视图 *根据从表里面拿出来的数据而创建出来的一张表 创建视图:create view v_t1 as select * from t1 where id>4 and id<11; 作用: 如果 t1表里的数据某条记录被删除原创 2014-08-11 15:23:57 · 652 阅读 · 0 评论 -
MySQL 正则表达是的使用
正则表达式的使用 --(注意匹配到了是1 没有则为0) select "linux is very ok" regexp ".*" ; --匹配所有 select "linux is very ok" regexp "^linux" --匹配以linux为开头的 ->通用的一些: ^ 在字符串的开始处进行匹配 a?原创 2014-08-11 15:28:49 · 850 阅读 · 0 评论 -
MySQL事务处理介绍
MySQL事务处理(增删改查后只要没有commit,全可以回滚) *myisam引擎不支持事务,innodb(支持外键和事务)才支持事务 修改表引擎方法:alter table t1 engine=innodb 一:事务操作 查看是否自动提交:select @@autocommit; 关闭自动提交 set autocommit=0;原创 2014-08-11 15:26:27 · 693 阅读 · 0 评论 -
MySQL 重排auto_increment值
重排auto_increment值 MySQL数据库自动增长的ID如何恢复: 清空表的时候,不能用delete from tableName; 而是用truncate tableName; 这样auto_increment就恢复成1了 或者清空内容后直接用alter命令修改表:alter table tableName auto_incre原创 2014-08-11 15:27:42 · 1288 阅读 · 0 评论 -
MySQL 密码丢失破解过程
root密码丢失 破解:(破解思路:跳过授权表,进去后能后在务修改密码) 1:server mysqld stop 2: mysqld_safe --skip-grant-tables --user=mysql & ->跳过授权表mysql.user和mysql.db这些表 3:mysql -uroot 4: set password=password("leya原创 2014-08-11 15:16:18 · 896 阅读 · 0 评论 -
MySQL 四种字符集问题 统一
四种字符集问题(尽量统一设置utf8) sql: \s 查看 服务器字符集:server characterset: utf8 数据库字符集:Db characterset:utf8 客户端字符集:client characterset:utf8 链接字符集:conn. characterset:utf8 怎么设置字符集:mysql配置文件中找到: [clie原创 2014-08-11 15:19:43 · 1002 阅读 · 0 评论 -
MySQL存储
MySQL存储(可以认为是自定义的函数) 创建一个存储: \d // create procedure p1() begin set @i=0; while @i<10 do insert into t2(name) values(concat("user",@i)); --这里可以做增删改查。。。都行 set @i=@i原创 2014-08-11 15:25:17 · 658 阅读 · 0 评论 -
MySQL慢查询开启和使用
查看慢查询是否开启:show variables like "%slow%"; --看slow_query_log 是否开启 --慢查询日志保存地址 slow_query_log_file -> E:\wamp\bin\mysql\mysql5.5.20\data\asus-PC-slow.logshow variables like "%long%"; --查看慢查询时间10s原创 2014-08-11 15:16:25 · 848 阅读 · 0 评论 -
MySQL表复制
MySQL表复制 复制表结构 + 复制表数据 create table t3 like t1; --创建一个和t1一样的表,用like(表结构也一样) insert into t3 select * from t1; --t1的数据全部拿过来,注意是表结构一致才select* ,否则选择相应的的字段列插入 create table t1( id int原创 2014-08-11 15:22:25 · 503 阅读 · 0 评论 -
MySQL触发器
MySQL触发器(自动执行) *查询没有必要做触发器!:select * from t1 union select * from t2; 一:增加触发器 \d // 创建一个名字为tg1的触发器,当向表中插入数据时,就向t2表中插入一条数据 create trigger tg1 before insert on t1 for each row begin原创 2014-08-11 15:28:49 · 579 阅读 · 0 评论 -
MySQL数据库DELAY_KEY_WRITE的认识
MySQL数据库DELAY_KEY_WRITE的认识原创 2015-05-19 18:56:15 · 1334 阅读 · 0 评论 -
MySQL 转换/修改表存储引擎 详细介绍
MySQL 表转换 (转换/修改表存储引擎)细节介绍原创 2015-06-08 14:08:18 · 1164 阅读 · 0 评论 -
MySQL创建索引导致锁及表锁阻塞查询
一:场景-- 原有表结构'CREATE TABLE `leyangjun_user_test` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `uid` int(11) NOT NULL DEFAULT '0' COMMENT 'uid', `supplier_id` int(11) NOT N...原创 2019-08-28 11:17:45 · 4320 阅读 · 0 评论 -
mysql select for update + 事务处理数据一致性
如果SELECT 后面若要UPDATE 同一个表数据的相关操作,最好使用SELECT ... FOR UPDATE。一:举例说明 假设商品表单test_leyangjun内有一个存放商品库存的num字段,一个id主键,在生成订单前须先确定num>0,然后才把数量更新。代码如下(比如现在的库存:num=3对应的id=3,现在生成一个订单需要对库存做扣减少): SEL...原创 2019-03-18 10:42:05 · 2563 阅读 · 1 评论 -
MySQL 普通索引191原因
最近在使用一个超长字段增加普通索引的时候发现后面自动追加了191,这是什么原因呢?原因: 单个索引最大长度是767字节,你用的编码是utf8mb4,这个最大可能一个字占4字节(767/4 约等于 191) 。也就是说字段长度超出了索引最大值能后MySQL 默认在普通索引追加了191...原创 2018-09-04 21:04:59 · 3062 阅读 · 0 评论 -
Error : Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in
mysql :Error : Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause 一个表中出现多个timestamp并设置其中一个为current_timestamp的时候经常会遇到这个错误例...原创 2018-07-06 15:01:50 · 1314 阅读 · 0 评论 -
PHP,MySql权限系统设计
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 表结构,仅供参考 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =CREATE DATABASE leyangjunDB;Create Table: CR...原创 2018-06-15 17:52:02 · 731 阅读 · 0 评论 -
php mysql使用like模糊搜索json的数据
案例:数据库存储的json进行模糊搜索$text = $data['text'];//leyangjun//$text = preg_replace("/\s/", "", $text);if (!empty($text)) { $json_text = str_replace("\\", "_", json_encode($text)); $json_text = strva...原创 2018-05-25 10:09:36 · 1896 阅读 · 0 评论 -
PHP MySql 模糊查询json数据
一般json格式的数据会对中文进行特殊处理,所以查询的时候需要处理下才行$name = "乐杨俊";$json_name=str_replace("\\","_",json_encode($name));$where .= " and extend_params like '%" . $json_name ."%' ";eg:语句出来后是这种格式: select * from user where...原创 2018-05-17 11:50:05 · 1272 阅读 · 1 评论 -
mysql Error : Cannot truncate a table referenced in a foreign key constraint 清空具有外键约束的表时报
mysql Error : Cannot truncate a table referenced in a foreign key constraint 清空具有外键约束的表时报原创 2017-02-13 11:29:59 · 2787 阅读 · 0 评论 -
MySql数据库细节使用规范详细解读胜过千行代码优化
MySql数据库细节使用规范详细解读胜过千行代码优化原创 2017-02-17 14:35:11 · 1180 阅读 · 1 评论 -
安装mysql报错问题处理
安装mysql报错问题处理原创 2017-01-11 10:29:40 · 598 阅读 · 0 评论 -
linux卸载mysql操作详细
linux卸载mysql操作详细原创 2017-01-11 11:57:13 · 318 阅读 · 0 评论 -
Navicat for MySQL 11注册码
Navicat for MySQL 11注册码转载 2016-12-15 18:06:42 · 25195 阅读 · 0 评论 -
MySQL慢查询Explain Plan分析
MySQL慢查询Explain Plan分析原创 2016-10-18 10:22:51 · 1135 阅读 · 0 评论 -
数据库高可用实战案例:架构优化
数据库高可用实战案例:架构优化翻译 2016-09-05 20:24:49 · 1292 阅读 · 1 评论 -
MySQL 高可用架构在业务层面细化分析研究
MySQL 高可用架构在业务层面细化分析研究原创 2016-02-23 14:45:56 · 5086 阅读 · 4 评论