Query, export, and import stored procedures in mysql

Source: Internet
Author: User

 

1. query stored procedures in a database

Method 1 (view the content of a specified Stored Procedure ):

Select body from mysql. proc where name = 'Procedure _ name ';

 

Method 2 (view all stored procedures ):

Show procedure status;

 

Ii. Export and Import MySQL stored procedures. Usage:

1. Export

[Root @ localhost bin] # mysqldump-uroot-p-hlocalhost-P3306-n-d-t-R DBName> procedure_name. SQL

Parameter description:

-N: -- no-create-db

-D: -- no-data

-T: -- no-create-info

-R: -- routines Dump stored routines (functions and procedures)

 

Mysqldump is a client tool used to back up databases or migrate data between different databases. The backup content contains the SQL statement used to create a live load table:

Main parameters:

1. connection options

-U, -- user = name

-P, -- password = name

-H, -- host = name

-P, -- port = #

2. Output content options

-- Add-drop-database

-- Add-drop-table

-N; -- no-create-db

-D; -- no-data

-T; -- no-create-info

3. output format options

-- Compact

-C -- complete-insert

-T (data backup in the specified data table is a simple data file and a table creation SQL file)

Note: The xx.sqltable file is created by the linux rootuser, And the xx.txt file is created by the linux mysql user. Therefore, the storage path of these two files must ensure that the mysql user has the permission to read and write the created files.

-- Fields-terminated-by = name (domain separator)

-- Fields-enclosed-by = name (domain quote)

-- Fields-optionally-enclosed-by = name (optional characters for domain reference)

-- Fields-escaped-by = name (Escape Character)

4. Character Set options

-- Default -- character-set = xx

5. Other options

-F -- flush-logs (refresh the log before backup)

-L -- lock-tables (apply a read lock to all tables)

2. Import

Mysql-hhostname-uusername-ppassword databasename <backupfile. SQL

This article is from the "from cisco to linux" blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.