Mysql導出函數、存儲過程


下面是導出存儲過程的代碼

1 # mysqldump -u 數據庫用戶名 -p -n -t -d -R 數據庫名 > 文件名

 

其中,-d 表示--no-create-db, -n表示--no-data, -t表示--no-create-info, -R表示導出function和procedure。所以上述代碼表示僅僅導出函數和存儲過程,不導出表結構和數據。但是,這樣導出的內容里,包含了 trigger。再往mysql中導入時就會出問題,錯誤如下:

ERROR 1235 (42000) at line **: This version of MySQL doesn't yet support ‘multiple triggers with the same action time and event for one table’

所以在導出時需要把trigger關閉。代碼為

 

1 # mysqldump -u 數據庫用戶名 -p -n -t -d -R --triggers=false 數據庫名 > 文件名

 

這樣導入時,會出現新的問題:

ErrorCode:1418
This function has none of DETERMINISTIC, NOSQL, or READS SQL DATA inits declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

解決方法是,在/etc/my.cnf中找到[mysqld],在它下面添加這樣一行:

 

1 log-bin-trust-function-creators=1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM