zoukankan      html  css  js  c++  java
  • mysql 运维相关

    查看mysql数据库中表的信息

    SELECT 
    TABLE_SCHEMA as `数据库`,table_name  AS  `表名`,  table_type  AS  `类型`,  engine      AS  `引擎`,VERSION AS`版本`,TABLE_COLLATION AS `字符集`
    FROM  information_schema.tables
    where TABLE_SCHEMA='xxx' and TABLE_COLLATION='xxx'
    ORDER BY table_name DESC;
    

    查看及设置binlog类型命令

    show variables like 'binlog_format'

    SET GLOBAL binlog_format = ROW;‘

    查看binlog日志内容

     show binlog events in 'mysql-bin.000002' from pos limit 111;

    mysqlbinlog --no-defaults  --start-position=267017770 --stop-position=267018454  --base64-output=DECODE-ROWS -v mysql-bin.000218 

    #--start-datetime='2019-04-11 00:00:00' --stop-datetime='2019-04-11 15:00:00'

    
    

     --base64-output=DECODE-ROWS 指定binlog格式

    mysql 慢日志分析工具命令

    mysql/bin/mysqldumpslow -s t -t 10 log/mysql/slow.log 

    mysql 违规删除数据库文件,恢复问题

    背景:启动数据库时报错(不影响启动),报错信息显示数据库文件不存在了

    原因是因为之前服务器上磁盘满了,同事直接把不用的数据库文件(.frm,.ibd)删了.  注:mysql版本5.6.21

    在网上搜索到的解决方案:https://yq.aliyun.com/ziliao/22686

    但是在实操过程中并不管用,可能存在场景或环境不一致的情况

    受该文章启发我这边也找到了解决方案

     cp -a mf_0810.frm ASocket2.frm

    1.随便找了个别的表的表结构,复制成丢失的文件的名字

    2.重新启动客户端,我用的是navicat,客户端中会显示出相应的表,对这些表逐一使用“右键删除表”

    问题解决

    查看mysql 当前在执行的查询

    show procressList

     select * from information_schema.processlist where db='mofangdata'  order by time desc;

    mysql 命令找不到时使用

    ln -s /ali/server/mysql/bin/mysql /usr/bin/mysql

     查看mysql当前负载

    select count(*) num,user,substring(host,1,15) from information_schema.processlist group by substring(host,1,11) order by num desc;

  • 相关阅读:
    hdu-5492 Find a path(dp)
    hdu-5493 Queue(二分+树状数组)
    bzoj-2243 2243: [SDOI2011]染色(树链剖分)
    codeforces 724
    codeforces 422A A. Borya and Hanabi(暴力)
    codeforces 442C C. Artem and Array(贪心)
    codeforces 442B B. Andrey and Problem(贪心)
    hdu-5918 Sequence I(kmp)
    poj-3739. Special Squares(二维前缀和)
    hdu-5927 Auxiliary Set(树形dp)
  • 原文地址:https://www.cnblogs.com/zhangyanhe/p/9002769.html
Copyright © 2011-2022 走看看