Navicat Premium 12.1.8.0安装与激活
https://www.jianshu.com/p/5f693b4c9468
https://www.jianshu.com/p/5f693b4c9468?mType=Group
linux 链接mysql
mysql -uroot -h 127.0.0.1 -p
分组后根据该组个数排序
SELECT *,count(*) as cnt from `bftv_order` where tvSn='console' GROUP BY uid order by cnt desc
锁
MySQL行级锁、表级锁、页级锁详细介绍
https://www.jb51.net/article/50047.htm
mysql锁
行级锁: 冲突少,但开销大速度慢
页级锁: 锁住所在行附近行
表级锁: 开销小速度快但冲突多
表被锁时可以读
表级锁更适合查询
行级锁更适合修改
1) 表级锁:开销小,加锁快;不会出现死锁;锁定粒度大,发生锁冲突的概率最高,并发度最低。
2) 行级锁:开销大,加锁慢;会出现死锁;锁定粒度最小,发生锁冲突的概率最低,并发度也最高。
3) 页面锁:开销和加锁时间界于表锁和行锁之间;会出现死锁;锁定粒度界于表锁和行锁之间,并发度一般。
MyISAM和MEMORY存储引擎采用的是表级锁(table-level-locking);
BDB存储引擎采用的是页面锁(page-level-locking),同时也支持表级锁;
InnoDB存储引擎既支持行级锁,也支持表级锁,默认情况下是采用行级锁。
InnoDB只有通过索引条件检索数据才是行锁,否则是表锁
亲测有效,解决Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) ";
https://blog.csdn.net/hjf161105/article/details/78850658
利用Linux系统生成随机密码的8种方法
https://www.cnblogs.com/dadonggg/p/8477655.html
E:\phpStudy\PHPTutorial\MySQL\bin>mysqld --initialize
E:\phpStudy\PHPTutorial\MySQL\bin>mysqld -install
E:\phpStudy\PHPTutorial\MySQL\bin>net start mysql
启动mysql
service mysql start
error while loading shared libraries: libaio.so.1: cannot open shared o错误解决
https://blog.csdn.net/tongtong0704/article/details/78933112
linux上安装mysql5.7
https://www.cnblogs.com/daemon-/p/9009360.html
mysql 查询当天、本周,本月,上一个月的数据
https://www.cnblogs.com/benefitworld/p/5832897.html
取消设置严格模式
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
mysql 不显示中文
set names utf8;
mysql 设置时区
set global time_zone = '+8:00';
flush privileges;
开启慢查询
https://blog.csdn.net/qq_40884473/article/details/89455740
【MySQL优化】——看懂explain
https://blog.csdn.net/jiadajing267/article/details/81269067
获取昨天和今天零点
昨天: UNIX_TIMESTAMP(CAST(SYSDATE()AS DATE) - INTERVAL 1 DAY)
今天:UNIX_TIMESTAMP(CAST(SYSDATE()AS DATE))
mysql查询时,查询结果按where in数组排序
order by field(id,2,7,1,4,3);
https://blog.csdn.net/qq_33980878/article/details/82660216
修改root密码
grant all privileges on *.* to root@'%' identified by 'root';
flush privileges;
使用SQL语句统计数据时sum和count函数中使用if判断条件
https://blog.csdn.net/qq784515681/article/details/80375494
调优
https://blog.csdn.net/xianqi45/article/details/78841811
连接数使用率(connections_used_ratio)
mysql > show global status like 'Max_used_connections';
mysql > show variables like 'max_connections%';
使用率 = Max_used_connections ÷ max_connections
– 判断方法
10% < 连接数使用率 < 85% . 若<10%,则表明最大连接数上限可能设置过高;若>85%,则表明连接数 不够用,或连接建立未释放.
msyql > show global status like 'handler_read%';
msyql > show global status like 'com_select';
表扫描数 = Handler_read_rnd_next ÷ Com_select
--若 表扫描数 > 4000,则表明存在大量全表扫描,即索引建立不合理或未正确使用索引;若 表扫描数 < 4000,且CPU高,则建议查看存储过程中循环分支是否进入死循环.