Home > Database > Mysql Tutorial > body text

MySQL储存过程的备份和还原技巧

WBOY
Release: 2016-06-07 16:52:50
Original
1066 people have browsed it

在转储的数据库中转储存储程序(函数和程序)。使用---routines产生的输出包含CREATE PROCEDURE和CREATE FUNCTION语句以重新创建子

在转储的数据库中转储存储程序(函数和程序)。使用---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(iinsert 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 

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!