· 9 years ago · Jan 16, 2017, 11:52 AM
1Open in notepad for tabing and word break :
2
3-- Making a Copy of a Database
4shell> mysqldump db1 > dump.sql
5shell> mysqladmin create db2
6shell> mysql db2 < dump.sql
7
8-- Copy a Database from one Server to Another
9Server 1:
10shell> mysqldump --databases db1 > dump.sql
11Server 2:
12shell> mysql < dump.sql
13
14-- Dumping Table Definitions and Content Separately
15shell> mysqldump --no-data test > dump-defs.sql
16shell> mysqldump --no-create-info test > dump-data.sql
17
18-- Dumping Data in SQL Format with mysqldump
19shell> mysqldump [arguments] > file_name //SQL statement as standard input
20shell> mysqldump --all-databases > dump.sql //Dumps all databases
21shell> mysqldump --databases db1 db2 db3 > dump.sql //Dumps specific databases
22shell> mysqldump --databases test > dump.sql //Dumps a single database
23shell> mysqldump test t1 t3 t7 > dump.sql //Dumps specific tables
24
25-- Reloading SQL-Format Backups
26shell> mysql < dump.sql
27mysql> source dump.sql //Declares source
28shell> mysqladmin create db1 //If the file is a single-database dump not containing CREATE DATABASE and USE statements, create the database first
29shell> mysql db1 < dump.sql //Then specify the database name when you load the dump file
30
31//Create database, select it as default and laod dump file
32mysql> CREATE DATABASE IF NOT EXISTS db1;
33mysql> USE db1;
34mysql> source dump.sql
35
36-- Dumping Data in Delimited-Text Format with mysqldump
37shell> mysqldump --tab=/tmp db1 // --tab=dir_name option, it uses dir_name as the output directory and dumps tables individually in that directory using two files for each table.
38shell> mysqldump --tab=/tmp --fields-terminated-by=, --fields-enclosed-by='"' --lines-terminated-by=0x0d0a db1 //Random ??? Nevem kaj to je
39
40-- Reloading Delimited-Text Format Backups
41shell> mysql db1 < t1.sql potem: mysql> USE db1;
42shell> mysqlimport db1 t1.txt -----> mysql> LOAD DATA INFILE 't1.txt' INTO TABLE t1;