日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql单表备份语句 +多表

發布時間:2024/9/15 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql单表备份语句 +多表 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

mysql單表備份語句

  • mysql單表備份

    SELECT CONCAT("mysqldump -uroot -p123456 ",table_schema," ",table_name," >/tmp/",table_schema,"_",table_name,".sql") FROM information_schema.tables WHERE table_schema NOT IN('sys','performance','information_schema') INTO OUTFILE '/tmp/bak.sh';

    INTO COUTFILE '/tmp.bak.sh'; --將查詢結果輸出保存到一個文件中

    FIELDS TERMINATED BY "," ENCLOSED BY '"'; -- 以逗號分割,引號包裹

  • 多表備份
    mysqldump -rp2p_sit -p --database p2p_sit --tables tablename1 tablename2 > ~/p2p_init.sql

  • 查詢整個數據庫中所有的庫對應的表明

    select table_schema, table_name from information_schema.tables;
  • 查詢world和school庫下所有的表明

    select table_schema, table_name from information_schema.tables where table_name = 'world' union all select table_schema, table_name from information_schema.tables where table_name = 'school';
  • 查詢整個數據庫中所有的庫對應的表明,每個庫顯示一行

    select table_schema, group_concat(table_name) from information_schema.tables group by table_schema;
  • 統計每個庫下的表的個數

    select table_schema, count(table_name) from information_schema.tables group by table_name;
  • 統計每個庫的真實數據量 (感覺有問題)

    # 每個表的數據量=AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH SELECT sum(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 as total_nb from information_schema.tables;
  • Concat拼接命令

    select concat(user,"@","'",host,"'") from mysql.user;
  • 對數據庫下的單張表進行單獨備份

    # world庫下的city表 mysqldump -uroot -p****** world city > /tmp/world_city.sql
  • 對整個數據庫下的1000張表進行單獨備份,排除sys,performance,information_schema。

    select concat("mysqldump -uroot -p******",table_schema," ",table_name," >/tmp/",table_schema,"_",table_name,".sql") from information_schema.tables where table_schema not in ("sys","performance","information_schema") into outfile '/tmp/bak.sh';
  • 總結

    以上是生活随笔為你收集整理的mysql单表备份语句 +多表的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。