mysqldump creates SQL file including table creations and data insertion statements.
[oracle@oraclelinux6 bin]$ MYSQL_UNIX_PORT=/home/oracle/software/mysql_5.6.19/data/mysql.sock [oracle@oraclelinux6 bin]$ export MYSQL_UNIX_PORT [oracle@oraclelinux6 bin]$ ./mysqldump -u root -p tpccdb5_10 >tpccdb5_10.sql ... -rw-rw-r-- 1 oracle oracle 95444709 Jul 24 10:28 tpccdb5_10.sql
You can use the created SQL file to restore the database as follows:
[oracle@oraclelinux6 bin]$ mysql56 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 81 Server version: 5.6.19 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database tpccdb5_10; Query OK, 1 row affected (0.00 sec) mysql> exit Bye [oracle@oraclelinux6 bin]$ ./mysql -u root -pmysql tpccdb5_10 < tpccdb5_10.sql
mysqldump by default will include the table, data and triggers but NOT the stored procedures/functions. To include the procedure, please add the --routines parameter. The following are parameter control the export data from mysqldump:
To import to another database, you can simply change the database name in the loading command:
- -- no-create-info: create tables FALSE by default
- -- no-data: data FALSE by default
- —routines: procedure/functions FALSE by default
- —triggers: trigger TRUE by default
To import to another database, you can simply change the database name in the loading command:
./mysql -u root -pmysql targetdb_name < tpccdb5_10.sql