• mysql常用操作


    #导出数据库结构
    mysqldump -uroot -h127.0.0.1 -P3306 -pxxxx --set-gtid-purged=OFF -BRE --events -d qfgn > qfgn_20190531.sql
    #导出数据库
    mysqldump -uroot -h127.0.0.1 -P3306 -pxxxx --set-gtid-purged=OFF -BRE --events qfgn > qfgn_20190531.sql
    #导出全部应用数据库
    time mysql -h${ip} -P${port} -uroot -pxxxx -e 'show databases;' | grep -Ev "Database|information_schema|mysql|performance_schema" | grep -v "^test$" | xargs mysqldump -uroot -pxxxx -h${ip} -P${port} --single-transaction --master-data=2 --flush-logs -BRE --set-gtid-purged=OFF --events > ./${pub_ip}_mysql.sql
    #导出表数据 mysqldump -uroot -h127.0.0.1 -P3306 -pxxxx --set-gtid-purged=OFF qfgn qfgn_sys_menu > qfgn_sys_menu.sql
    #导出表结构
    mysqldump -uroot -h127.0.0.1 -P3306 -pxxxx --set-gtid-purged=OFF -d qfgn qfgn_sys_menu > qfgn_sys_menu.sql


    #导入数据库
    time mysql -h127.0.0.1 -P3336 -uroot -pxxxx < ./${pub_ip}_mysql.sql

    #导入表数据
    time mysql -h127.0.0.1 -P3336 -uroot -pxxxx qfgn < qfgn_sys_menu.sql

    #导出指定条件的数据
    mysqldump -uroot -h127.0.0.1 -P3306  -pxxxx 库名 表名 --where="id < 386" > menu_new_385.sql
    查看mysql库大小,表大小,索引大小:
    
    进入information_schema库
    mysql> use information_schema;
    查看所有库的大小
    mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from TABLES;
    查看指定库的大小
    mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from TABLES where table_schema='jishi';
    查看指定库的指定表的大小
    mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from TABLES where table_schema='jishi' and table_name='a_ya';
    查看指定库的索引大小
    mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' FROM TABLES  WHERE table_schema = 'jishi';
    查看指定库的指定表的索引大小
    mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' FROM TABLES  WHERE table_schema = 'test' and table_name='a_yuser';
    查看一个库中的情况...
    mysql>  SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name', CONCAT(ROUND(table_rows/1000000,4),'M') AS 'Number of Rows', CONCAT(ROUND(data_length/(1024*1024*1024),4),'G') AS 'Data Size', CONCAT(ROUND(index_length/(1024*1024*1024),4),'G') AS 'Index Size', CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),4),'G') AS'Total'FROM information_schema.TABLES WHERE table_schema LIKE 'test';
    查询操作
    
    按照log_time字段排序:
    select * from log_science order by log_time;
    
    限制显示输出条数
    select * from log_science order by log_time desc limit 10;
  • 相关阅读:
    【杭电ACM】1.2.4 Financial Management
    【杭电ACM】1.2.1 Biker's Trip Odometer
    【杭电ACM】1097 A hard puzzle
    【西交ACM】100 A+B problem
    【杭电ACM】1.2.2 Climbing Worm
    【杭电ACM】1004 Let the Balloon Rise
    【杭电ACM】1.2.3 hide handkerchief
    【杭电ACM】1.2.5 find your present (2)
    【杭电ACM】1.2.6 decimal system
    【西交ACM】298 第N大的数
  • 原文地址:https://www.cnblogs.com/chenjw-note/p/10954547.html
Copyright © 2020-2023  润新知