In mysql, you can use the "mysqldump -uroot -p -hlocalhost -P3306 -n -d -t -R DBName > procedurename.sql" statement to export a single stored procedure.
(Recommended tutorial: mysql video tutorial)
View the specified stored procedure content:
select body from mysql.proc where name='procedurename';
View all stored procedures:
show procedure status;
Export MySQL stored procedures
mysqldump -uroot -p -hlocalhost -P3306 -n -d -t -R DBName > procedurename.sql
Parameter description:
-n : --no-create-db
-d: --no-data
-t: --no-create-info
-R: --routines Dump stored routines (functions and procedures)
Main parameter introduction:
Character set Options
--default--character-set=xx
Connection options
- u,--user=name
-p,--password=name
-h,--host=name
-P,--port=
#Output content options
--add-drop- database
--add-drop-table
-n;--no-create-db
-d;--no-data
-t;--no-create-info
Output format options
--compact
-c --complete-insert
-T (specify data The data backup in the table is a simple data file and a table-building SQL file)
Note that the xx.sql table-building file is created by the Linux root user,
The xx.txt file is created by a Linux mysql user,
Therefore, the storage paths of these two files must ensure that the mysql user has the permission to read, write and create files.
--fields-terminated-by=name (field delimiter)
--fields-enclosed-by=name (field reference characters)
--fields-optionally-enclosed-by=name (field reference optional characters)
--fields-escaped- by=name (escape characters)
Others
-F --flush-logs (refresh logs before backup)
-l --lock-tables (Add read locks to all tables)
Import MySQL stored procedures
mysql -hhostname -uusername - ppassword databasename < backupfile.sql
The above is the detailed content of How to export a single stored procedure in mysql?. For more information, please follow other related articles on the PHP Chinese website!