mysql查询表大小
工作中常用命令参考,收集如下:
查询表大小:
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
上一篇: MySQL修炼之路四
下一篇: 鱼人