# pid fileshow variables like '%pid_file%';# socketshow variables like '%socket%'; # page size default:16KBshow variables like 'innodb_page_size';-- 显示数据库版本号,存储引擎等信息show variables like '%version%'; show variables like '%innodb_version%'; -- 观察InnoDB的IO Threadshow engine innodb status;-- InnoDB 缓存池设置;缓存索引页,数据页;show variables like '%innodb_buffer_pool_size%'; -- 多个缓存池实例show variables like '%innodb_buffer_pool_instance%'; -- 两次写show global status like '%innodb_dblwr%';-- 查看当前的通用日志是否开启show variables like '%general%';-- 慢查询日志show variables like '%query%';-- 如果该值是ON,则会记录所有没有利用索引来进行查询的语句,前提是slow_query_log 的值也是ON,否则,不会奏效show variables like '%log_queries_not_using_indexes%';-- 错误日志show variables like '%log_err%';-- 二进制日志-- 删除所有二进制文件:-- reset master-- 删除部分二进制文件:-- purge master logs-- 查看是否启用二进制日志:-- show variables like '%log_bin%';-- 查看所有的二进制参数-- show variables like '%binlog%';-- 查看文件的位置-- show variables like '%datadir%';-- undo logshow variables like '%innodb_undo_logs%';show variables like '%undo%';-- innodb_max_undo_log_size:当undo表空间超过该参数设定时,会标记为truncation,选择一个undo表空间进行截断-- innodb_undo_directory :undo表空间存放目录-- innodb_undo_log_truncate :参数设置为1,即开启在线回收(收缩)undo log日志文件,支持动态设置-- innodb_undo_logs :设置rollback segment的个数-- innodb_undo_tablespaces :设置构成rollback segment文件的数量,这样可以较为平均的分布在多个文件中-- 1.insert undo log-- 指在insert操作中产生的undo log,因为insert操作的记录只对事务本身可见。因此该undo log在事务提交后直接删除,不需要进行purge操作。-- 2.update undo log-- 记录的是对delete和update操作产生的undo log,该log需要提供mvcc机制,因此不能在事务提交时就进行删除。提交时放入undo log链表,等待purge线程进行清除。-- redo log-- 参数innodb_log_file_size指定了redo log的大小-- innodb_log_file_in_group指定了redo log的数量-- innodb_log_group_home_dir指定了redo log所在路径show variables like '%innodb_log%';-- 事务超时时间SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';-- 设置当前session不自动提交SHOW VARIABLES LIKE '%autocommit%';-- SET autocommit = 0;SELECT * FROM information_schema.INNODB_TRX;SELECT *FROM information_schema.processlistWHERE id = 15106;select count(1) from print_bg_trade where enable=1desc select * from print_bg_trade where enable=1 limit 10-- 查看 当前session是否打开了profile功能-- show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情况SELECT @@profiling;SHOW VARIABLES LIKE '%profile%';-- 开启 profiling 参数-- SET profiling = 1;SHOW PROFILES;SHOW PROFILE CPU, BLOCK IO FOR QUERY 1;-- 查找数据库文件位置使用命令SHOW GLOBAL VARIABLES LIKE "%datadir%";-- 查询日志文件路径SHOW VARIABLES LIKE 'general_log_file';SHOW VARIABLES LIKE 'general_log';-- set global log_output=file;//输出到文件-- set global general_log_file='file-path.log';//输出文件地址-- 开启通用日志-- set global general_log=on;-- 关闭通用日志-- set global general_log=off;-- 错误日志文件路径show variables like 'log_error';-- 慢查询日志文件路径show variables like '%slow%';-- 如果不清楚MySQL当前使用的配置文件路径,可以尝试这样查看: -- mysqld --verbose --help|grep -A 1 'Default options'show variables like 'log%'; show master logs; -- 查看慢查询相关参数show variables like 'slow_query%';show VARIABLES like 'slow_query_log';show variables like 'long_query_time';-- sql未使用索引,是否记录到慢sql日志中show variables like 'log_queries_not_using_indexes';-- 5.6.5之后,表示每分钟记录到slow log的且未使用索引的SQL语句次数;默认值0show variables like 'log_throttle_queries_not_using_indexes';-- 开启慢sql日志-- SET GLOBAL slow_query_log = 'ON';-- 查询超过1秒就记录-- SET GLOBAL long_query_time = 1;-- 查看MySQLbinlog模式show global variables like "binlog%";-- 查看二进制日志是否打开,本地是关的(开启需要 配置my.conf并重启)SHOW VARIABLES LIKE 'log_bin';-- 查看binlog 文件的目录位置SHOW VARIABLES LIKE 'datadir';-- 查看最新的binlogshow master status;-- 时间范围可选,查询一定范围的binlog-- mysqlbinlog --start-datetime="2018-07-31 19:25:00" --stop-datetime="2018-07-31 20:25:00" binlog.000001-- 使用 -vv 时候可以看到 每一列的 metadata-- mysqlbinlog --start-datetime="2018-07-31 19:25:00" --stop-datetime="2018-07-31 20:25:00" --base64-output=decode-rows -vv binlog.000001-- start-datetime 开始时间-- stop-datetime 结束时间-- database=resource 选择数据库-- result-file 结果输出到某个文件-- base64-output=decode-rows -- verbose -- MySQL中设置binlog模式-- set global binlog_format='ROW';-- 通过设置binlog过期的时间,使系统自动删除binlog文件show variables like 'binlog_expire_logs_seconds'; show variables like '%binlog%'; -- 设置binlog多少天过期-- set global binlog_expire_logs_seconds = 259200; -- Mysqlbinlog解析工具select count(1) from print_bg_trade;show master statusshow master logs; #查看数据库所有日志文件。-- 将内存中log日志写磁盘,保存在当前binlog文件中,并产生一个新的binlog日志文件。 -- flush logs; -- 删除所有二进制日志,并重新(mysql-bin.000001)开始记录。-- reset master;-- 1、如果是整个表复制表达如下:-- insert into table1 select * from table2-- 2、如果是有选择性的复制数据表达如下:-- insert into table1(column1,column2,column3...) select column1,column2,colunm3... from table2-- 3、一个数据库中的表中的数据复制到另一个数据库中的一个表,使用方法如下:-- insert into 数据库A.dbo.table1(col1,col2,col3...) select col1,col2,col3... from 数据库B.dbo.table2-- 查询目前数据库的连接情况:-- SELECT DISTINCT connection_type from performance_schema.threads where connection_type is not null;-- https://github.com/tianyk/py_innodb_page_info-- chmod 777 filename.py-- /Users/xjt2016/github/py_innodb_page_info/py_innodb_page_info.py /usr/local/var/mysql/kdzs_xcx/sys_user.ibd -v-- hexdump复制代码