Introduction to mysql import and export database as well as functions and stored procedures


mysql commonly used export data commands: 1.mysql exports the entire database mysqldump -hhostname -uusername -ppassword databasename > backupfile. sql mysqldump -hlocalhost -uroot hqgr > hqgr.sql (if the user of root doesn’t have a password, you can not write -p. Of course, you can make a path for the exported sql file. If it is not specified, it will be stored in the bin directory of mysql)

2.mysql exports 1 database table mysqldump-hhostname-uusername-ppassword database tablename > Exported file name mysqldump-hlocalhost-uroot hqgr t_ug_user > user.sql

3.mysql exports 1 database structure mysqldump-hhostname-uusername-ppassword-d — add-drop-table databasename > d:hqgrstructure.sql -d has no data — add-drop-table adds 1 drop table before each create statement

4. If you need to export functions or stored procedures in mysql mysqldump -hhostname -uusername -ppassword -ntd -R databasename > backupflie.sql mysqldump -hlocalhost -uroot -ntd -R hqgr > hqgr.sql Where -ntd is the exported stored procedure; -R is the derived function

mysql commonly used commands to import data: 1. mysql command mysql -hhostname -uusername - ppassword databasename < backupfile.sql 2. source command mysql > source backupfile.sql