MySQL儲存過程的備份與還原技巧

來源:互聯網
上載者:User

在轉儲的資料庫中轉儲儲存程式(函數和程式)。使用---routines產生的輸出包含CREATE PROCEDURE和CREATE FUNCTION語句以重新建立子程式。但是,這些語句不包括屬性,例如子程式定義者或建立和修改時間戳記。這說明當重載子程式時,對它們進行建立時定義者應設定為重載使用者,時間戳記等於重載時間。

如果你需要建立的子程式使用原來的定義者和時間戳記屬性,不使用--routines。相反,使用一個具有mysql資料庫相應許可權的MySQL賬戶直接轉儲和重載mysql.proc表的內容。

show procedure status;

show create procedure autoinsert;

DELIMITER ;;

CREATE PROCEDURE `autoinsert`()
begin
declare i int;
set i=1;
while(i<100000)do
insert into t10 values (i,'name');
set i=i+1;
end while;
END;;

DELIMITER ;

備份mysqldump -u root -p123 --socket=/usr/local/mysql1/var/mysql.sock -R --no-data --no-create-db --no-create-info --all-database > /root/mysqllog/test.sql

mysqldump -u root -p123 --socket=/usr/local/mysql1/var/mysql.sock mysql proc > /root/mysqllog/test.sql

還原source /root/mysqllog/test.sql

use mysql
source /root/mysqllog/test.sql 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.