How to backup stored procedures in MySQL

这一生的挚爱 提交于 2019-12-03 06:59:30

问题


I use mysqldump with MySQL 5.0 and I back it up every day, but do not understand the method that only stored procedure backs up.

How can I back it up?


回答1:


I'm not sure whether you're asking to back up stored procedures as well as everything else, or just the stored procedures on their own...

Stored procedured in dump with everything else:

mysqldump -R <dbname> #or
mysqldump --routines <dbname>

Just the stored procedures:

mysqldump -n -t -d -R <dbname> #or
mysqldump --no-create-db --no-create-info --no-data --routines <dbname>

Does that help?




回答2:


You can also put routines=true in the [mysqldump] section of your my.cnf file (you may have to add this section as it is not usually present in a virgin my.cnf file) to include routines in a normal dump.




回答3:


mysqldump - u dbusername (ex: -uroot) -ppassword (ex:-pmysql@dbpas) --routines <dbname>

use the username and password could be more helpful.



来源:https://stackoverflow.com/questions/881223/how-to-backup-stored-procedures-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!