procedurename.sql" statement to export a single stored procedure."/> procedurename.sql" statement to export a single stored procedure.">

Home >Database >Mysql Tutorial >How to export a single stored procedure in mysql?

How to export a single stored procedure in mysql?

青灯夜游
青灯夜游Original
2020-10-12 11:13:072849browse

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.

How to export a single stored procedure in mysql?

(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!

Statement:
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