用户

--- 创建用户
ALTER USER 'root'@'<Your Hostname>' IDENTIFIED WITH mysql_native_password BY '<Your Password>';

查看数据库大小与容量

select 
table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

select 
table_schema as '数据库',
sum(table_rows) as '记录数',
sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',
sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'
from information_schema.tables
where table_schema='kafka_eagle'
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;

查看某个库中的各个表的大小与容量:

select 
table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
order by data_length desc, index_length desc;

select 
table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
where table_schema='mysql'
order by data_length desc, index_length desc;

查看进程:

select * from information_schema.processlist\G

复制:主库

查看主库有哪些从库:

mysql> select * from information_schema.processlist where lower(state) like 'master has sent%'\G
*************************** 1. row ***************************
           ID: 6
         USER: replme
         HOST: 192.168.11.12:13465
           DB: NULL
      COMMAND: Binlog Dump
         TIME: 3194
        STATE: Master has sent all binlog to slave; waiting for more updates
         INFO: NULL
      TIME_MS: 3193874
    ROWS_SENT: 0
ROWS_EXAMINED: 0
1 row in set (0.01 sec)

mysql> 

复制:从库

查看从库端复制状态:

show slave status\G

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

隐藏
变装