錯誤:FUNCTION config_get does not exist。檢查 SHOW PROCEDURE STATUS 為空 → 匯出時未包含儲存程序。
mysqldump -u user -p -n -t -d -R dbname > routines.sql
# -n (--no-data) 不導資料
# -t (--no-create-info) 不導 CREATE TABLE
# -d (--no-create-db) 不導 CREATE DATABASE
# -R (--routines) 導出 FUNCTION/PROCEDURE
ERROR 1235 (42000): This version of MySQL doesn't yet support
'multiple triggers with the same action time and event for one table'
原因:-R 會連帶匯出 Trigger,若目標庫已存在同名 Trigger → 衝突。
解決:顯式關閉 Trigger 匯出
mysqldump -u user -p -n -t -d -R --triggers=false dbname > routines.sql
Error Code: 1418
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA
in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators variable)
原因:啟用 Binlog 時,創建函數需聲明確定性/無副作用,否則複寫不安全。
解決:/etc/my.cnf [mysqld] 區段添加
log_bin_trust_function_creators = 1
重啟 MySQL 生效。或修改函數定義添加 DETERMINISTIC/READS SQL DATA(推薦)。
# 1. 修改配置
echo "log_bin_trust_function_creators = 1" >> /etc/my.cnf
systemctl restart mysqld
# 2. 匯入儲存程序
mysql -u user -p dbname < routines.sql
# 3. 驗證
mysql -u user -p -e "SHOW PROCEDURE STATUS WHERE Db='dbname';"
mysql -u user -p -e "SHOW FUNCTION STATUS WHERE Db='dbname';"
DETERMINISTIC / NO SQL / READS SQL DATA / MODIFIES SQL DATA