MySQL常用的日常管理工具

來源:互聯網
上載者:User

標籤:

 

mysqldump

【--opt預設選項】

-A 全庫  -B指定庫  -E計劃任務 -R預存程序函數

mysqldump -uroot -proot -E -R -A  匯出的是基於-A的預存程序、函數和計劃任務

mysqldump -uroot -proot -E -R -B  匯出的是基於-B的預存程序、函數和計劃任務

 

--default-character-set=utf8 預設字元集utf8

--lock-all-tables  提交請求鎖定所有資料庫中的所有表,以保證資料的一致性,會造成事務的隱式提交

--master-data  該選項將binlog的位置和檔案名稱追加到輸出檔案中

--dump-slave  該選項將主的binlog位置和檔案名稱追加到匯出資料的檔案中

--flush-logs  開始匯出之前重新整理日誌

--ignore-table=mysql.user --ignore-table=mysql.db

--no-create-db,  -n    只匯出資料,而不添加CREATE DATABASE 語句。

--no-create-info,  -t    只匯出資料,而不添加CREATE TABLE 語句。

--no-data, -d    不匯出任何資料,只匯出資料庫表結構。

--single-transaction 該選項不會阻塞任何應用程式且能保證匯出時資料庫的一致性狀態。

--include-master-host-port 在--dump-slave語句中增加‘MASTER_HOST=<host>,MASTER_PORT=<port>‘

匯出表結構:

mysqldump  -E -R -B db_xx  --no-data  --skip-add-drop-table -u user_xx -p pwd_xx >xxx.sql

從上導資料:

mysqldump  -E -R -B db_xx  --dump-slave --single-transaction  --skip-add-drop-table -u user_xx -p pwd_xx >xxx.sql

主上導資料:

mysqldump  -E -R -B db_xx  --master-data --single-transaction  --skip-add-drop-table -u user_xx -p pwd_xx >xxx.sql

 

mysqldump  -E -R -B insurance  --no-data  --skip-add-drop-table -u root -p >insurance20160331.sql

mysqldumpslow

* -s, 是表示按照何種方式排序

            c 記錄次數    t 時間   l 查詢時間 r 回的記錄數  

            ac、at、al、ar,表示相應的倒序;

* -t, 是top n的意思,即為返回前面多少條的資料;

* -g, 後邊可以寫一個正則匹配模式,大小寫不敏感的;

mysqldumpslow -s c -t 10 /database/mysql/slow-log

 

mysqlbinlog

mysqlbinlog -u user_xx -p pwd_xx -P3306 -hlocalhost

-d 資料庫名 -R 讀取二進位日誌

 --start-datetime=datetime  指定開始時間,--start-datetime=‘2010-09-04 9:59:59‘

 --stop-datetime=datetime   指定結束時間

 --start-position=數字     指定開始位置

 --stop-position=數字      指定結束位置 (基於位置的更加精確)

 --no-default    不使用預設值

mysqlbinlog --start-position=134 --stop-position=330 mysqlbin-log.000001 >test1.txt

mysqlbinlog --start-datetime=‘2016-03-10 21:00:00‘  

mysqlbinlog -uroot -p -hlocalhost -vv --start-datetime=‘2016-03-10 21:00:00‘   mysql-bin.000098|more  

 

MySQL常用的日常管理工具

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.