zoukankan      html  css  js  c++  java
  • mysql

    查询表信息

    --  查询自动提交
    show VARIABLES like 'autocommit';
    -- 修改自动提交
    set autocommit=1;
    -- 查看表信息
    show table status like 'student';

     性能剖析

    -- 性能剖析开启状态
    show VARIABLES like 'profiling';
    -- 性能剖析
    show profiles;

    比如先执行一条语句select * from user;

    再执行show profiles; 可以看到结果中有语句的执行时间

     接下来执行

    show profile for query 35;

    可以看到具体的执行步骤占用时间

    不过这里是按照顺序排序的,要想按耗时排序,可以使用以下语句

    select state,sum(duration) as Total_R,
    round(100*sum(duration)/
    (select sum(duration) from information_schema.PROFILING
    where query_id=35),2)as Pct_R,
    count(*) as Calls,
    sum(duration)/count(*) as "R/Call"
    from information_schema.PROFILING
    where query_id=35
    GROUP BY state
    ORDER BY Total_R DESC;

     show CREATE table + 表名

     查询索引

    show index from 表名;

     查询状态

    show full processlist;

     

     Command列Query表示线程正在执行查询或者正在将结果发送给客户端。

     使用show status

    show status WHERE variable_name like 'HANDLER%' or variable_name like 'created%';

    使用show PROCESSLIST

    mysql复制

    主库:10.15.4.155

    从库:10.15.4.156

    在主库和从库创建账号并赋予复制权限

    grant replication slave,replication client on *.* to repl@'10.15.4.%' identified by 'xxx'

    先查看配置

    which mysqld

    结果是/usr/sbin/mysqld

    再运行

    /usr/sbin/mysqld --verbose --help | grep -A 1 'Default options'

    结果是

    Default options are read from the following files in the given order:
    /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf

    编辑主库的/etc/my.cnf,加入以下配置

    log_bin=mysql-bin
    server_id=10

    重启MySQL,查看主库状态

    show master status;

    编辑从库的配置

    log_bin=mysql-bin
    server_id=2
    relay_log=/var/lib/mysql/mysql-relay-bin
    log_slave_updates=1

     连接主库

    change master to master_host='10.15.4.155',
    master_user='repl',
    master_password='xxxx',
    master_log_file='mysql-bin.000001',
    master_log_pos=0;

    查看从库状态

    show slave status;

    启动复制

    start slave;

    再次查看状态

    查看主库进程

    show processlistG

    查看从库进程

  • 相关阅读:
    CSS3单选动画
    CSS3不一样的下拉选择框
    CSS3实现3d菜单翻转
    CSS3实现加载数据动画2
    CSS3实现加载数据动画1
    MySQL事务隔离级别和Spring事务关系介绍(转载)
    Elasticsearch7.5&Kibana7.5安装
    用nginx实现https请求转http请求(转)
    elasticsearch中多个字段聚合两种方法介绍
    window 同时安装python2和python3
  • 原文地址:https://www.cnblogs.com/uptothesky/p/8890670.html
Copyright © 2011-2022 走看看