Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query, export and import stored procedures in mysql

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report