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

How to export a single stored procedure in mysql?

青灯夜游
Release: 2020-10-12 11:13:07
Original
2814 people have browsed it

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';
Copy after login

View all stored procedures:

show procedure status;
Copy after login

Export MySQL stored procedures

mysqldump -uroot -p -hlocalhost -P3306 -n -d -t -R DBName > procedurename.sql
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template