How to query, export and import stored procedures in mysql
This article mainly describes how to query and export, import mysql storage process, the text is very detailed, has a certain reference value, interested friends must read!
I. Stored procedures in queries
Method 1 (View the contents of the specified stored procedure):
select body from .proc where name='procedure_name';
Method 2 (see all stored procedures):
show procedure status;
Second, MySQL stored procedure export and import, the specific usage is:
1. derived
[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-side tool used to backup databases or migrate data between different databases. The backup content contains SQL statements that create the live-mount table:
Main parameters:
1. connectivity 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 (specify that the data backup in the data table is a simple data file and a table SQL file)
Note: xx.sql table creation file is created by Linux root user, while xx.txt file is created by a Linux mysql user, so the storage path of these two files must ensure that mysql users have read and write permissions to create files.
--fields-terminated-by=name (field delimiter)
--fields-enclosed-by=name (domain reference)
--fields-optionally-enveloped-by =name
--fields-escaped-by=name(escape character)
4. Character Set Options
--default--character-set=xx
5. other options
-F --flush-logs
-l --lock-tables(read locks all tables)
2. import
mysql -hhostname -uusername - ppassword databasename < backupfile.sql
The above is "how to query and export, import mysql stored procedures" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!