Mysql Import and Export includes functions or stored procedures

Source: Internet
Author: User
Tags mysql import


Mysql Import and Export includes functions or stored procedures 1. mysql exports the entire database mysqldump-h hostname-u username-p databasename> backupfile. SQL if the root user does not use the password, you can not write-p. Of course, you can create a path for the exported SQL file. If it is not specified, it will be stored in the bin directory of mysql www.2cto.com 2. mysql exports a database table mysqldump-hhostname-uusername-ppassword database tablename> the exported file name mysqldump-hlocalhost-uroot hqgr t_ug_user> user. sql3.mysql export a database structure mysqldump-hhostname-uusername-ppassword-d -- add-drop-table database Name> d: hqgrstructure. SQL-d has no data -- add-drop-table adds a drop table4before each create statement. If you need to export functions or stored procedures in mysql mysqldump-h hostname-u username-ntd- R databasename> backupflie. SQL (including stored procedures and full function export at one time) where-ntd indicates the export table structure and data; -R indicates the export function and stored procedure. You can refer to the Command mysqldump -- help mysql commonly used to import data: mysql Database Import and Export: mysqldump-u username-p Database Name> database name. for example, mysqldump-u root-p testdb> testdb. SQL (excluding stored procedures and functions) mysqldump-u root-p-R tes Tdb> testdb. SQL (** including stored procedures and functions **) MySQL source command imports data into the database: mysql> use testdb; mysql> set names utf8; mysql> source/tmp/bdc. SQL; strange error handling: Below is the code for exporting the Stored Procedure 1 # mysqldump-u database username-p-n-t-d-R Database Name> file name, -d indicates -- no-create-db,-n indicates -- no-data,-t indicates -- no-create-info, and-R indicates exporting function and procedure. Therefore, the above Code only exports functions and stored procedures, and does not export table structures and data. However, the exported content contains the trigger. When importing data to mysql, the following ERROR occurs: ERROR 1235 (42000) at line **: this version of MySQL doesn't yet support 'Multiple triggers with the same action time and event for one Table'. Therefore, trigger must be disabled during export. The code is 1 # mysqldump-u database username-p-n-t-d-R -- triggers = false Database Name> when the file name is imported like this, a new problem occurs: ErrorCode: 1418 This function has none of DETERMINISTIC, NOSQL, or reads SQL DATA inits declaration and binary logging is enabled (you * might * want to use the less safe log_bin_trust_function_creators variable) solution is, in/etc/my. find [mysqld] In cnf and add the following line: 1 log-bin-trust-function-creators = 1 create database 'tota L_admin 'default character set utf8 COLLATE utf8_general_ci; 1. view mysql size use Database Name SELECT sum (DATA_LENGTH) + sum (INDEX_LENGTH) FROM information_schema.TABLES where TABLE_SCHEMA = 'database name'; the result is in bytes, except K for 1024, except 1048576, It is M. 2. view the last mysql modification time of the table. select TABLE_NAME, UPDATE_TIME from INFORMATION_SCHEMA.tables where TABLE_SCHEMA = 'database name ';

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.