当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql查询表大小

mysql查询表大小

2019年10月19日  | 移动技术网IT编程  | 我要评论

 

  工作中常用命令参考,收集如下:

查询表大小:
select table_name, data_length from information_schema.tables where table_schema='testtable';

查询表行数(基于information_schema)
select t.table_schema,t.table_name,t.table_rows,t.create_time,t.update_time from information_schema.tables t where t.table_name='history' and t.table_schema='zabbix' order by t.create_time desc,t.update_time desc;

查询所有表行数降序(基于information_schema)
select t.table_schema,t.table_name,t.table_rows,t.create_time,t.update_time from information_schema.tables t where t.table_schema='zabbix' order by t.table_rows desc;


mysql用户授权:
grant all on *.* to testtable@'%' identified by "123456";

初始化mysql实例
mysqld --defaults-file=/data0/mysql/3306/my.cnf --initialize-insecure --user=mysql

mysql导出表结构:
mysqldump -s mysql.sock -d app > app_0330.sql

dump避免gtid导出
mysqldump -s mysql.sock --set-gtid-purged=off -b app > app.sql

innobackupex恢复:
innobackupex --defaults-file=/data0/mysql/3307/my.cnf --apply-log /home/my3307back/2018-03-20_03-00-01/
innobackupex --defaults-file=/data0/mysql/3307/my.cnf --copy-back /home/my3307back/2018-03-20_03-00-01/
chown mysql.mysql -r /data0/mysql/3306/data

基于时间pos点的恢复:
mysqlbinlog --start-position=113927317 --stop-position=220222447 mysql-bin.000016 |mysql -s mysql.sock

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网