~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/clients/drizzledump.rst

  • Committer: Brian Aker
  • Date: 2010-12-17 00:08:06 UTC
  • mfrom: (2002.1.4 clean)
  • Revision ID: brian@tangent.org-20101217000806-fa6kmggjnhsl4q85
Rollup for field encapsulation, monty fix for bzrignore, and Andrew bug
fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
Synopsis
5
5
--------
6
6
 
7
 
:program:`drizzledump` [:ref:`OPTIONS <drizzledump-options-label>`] *database* [*tables*]
8
 
 
9
 
:program:`drizzledump` [:ref:`OPTIONS <drizzledump-options-label>`] :option:`--databases` *DB1* [*DB2* *DB3*...]
10
 
 
11
 
:program:`drizzledump` [:ref:`OPTIONS <drizzledump-options-label>`] :option:`--all-databases`
 
7
**drizzledump** [*OPTIONS*] *database* [*tables*]
 
8
 
 
9
**drizzledump** [*OPTIONS*] *--databases* [*OPTIONS*] *DB1* [*DB2* *DB3*...]
 
10
 
 
11
**drizzledump** [*OPTIONS*] *--all-databases* [*OPTIONS*]
12
12
 
13
13
Description
14
14
-----------
24
24
Any binary data in tables will be converted into hexadecimal output so that it
25
25
does not corrupt the dump file.
26
26
 
27
 
.. _drizzledump-options-label:
28
 
 
29
27
Drizzledump options
30
28
-------------------
31
29
 
32
30
The :program:`drizzledump` tool has several available options:
33
31
 
34
 
.. option:: --all-databases, -A
35
 
 
36
 
Dumps all databases found on the server apart from ``information_schema`` and
37
 
``data_dictionary`` in Drizzle and ``information_schema``,
38
 
``performance_schema`` and ``mysql`` in MySQL.
39
 
 
40
 
.. option:: --force, -f
41
 
 
42
 
Continue even if we get an sql-error.
43
 
 
44
 
.. option:: --help, -?
45
 
 
46
 
Show a message with all the available options.
47
 
 
48
 
.. option:: --lock-all-tables, -x
49
 
 
50
 
Locks all the tables for all databases with a global read lock.  The lock is
51
 
released automatically when :program:`drizzledump` ends.
52
 
Turns on :option:`--single-transaction` and :option:`--lock-tables`.
 
32
.. option:: -A, --all-databases
 
33
   
 
34
   Dumps all databases found on the server apart from *information_schema* and
 
35
   *data_dictionary* in Drizzle and *information_schema*, *performance_schema*
 
36
   and *mysql* in MySQL.
 
37
 
 
38
.. option:: -f, --force
 
39
 
 
40
   Continue even if we get an sql-error.
 
41
 
 
42
.. option:: -?, --help
 
43
 
 
44
   Show a message with all the available options.
 
45
 
 
46
.. option:: -x, --lock-all-tables
 
47
 
 
48
   Locks all the tables for all databases with a global read lock.  The lock is
 
49
   released automatically when :program:`drizzledump` ends.
 
50
   Turns on :option:`--single-transaction` and :option:`--lock-tables`.
53
51
 
54
52
.. option:: --single-transaction
55
53
 
56
 
Creates a consistent snapshot by dumping the tables in a single transaction.
57
 
During the snapshot no other connected client should use any of the
58
 
following as this will implicitly commit the transaction and prevent the
59
 
consistency:
60
 
 
61
 
.. code-block:: mysql
62
 
 
63
 
        ALTER TABLE
64
 
        DROP TABLE
65
 
        RENAME TABLE
66
 
        TRUNCATE TABLE
67
 
 
68
 
Only works with InnoDB.
 
54
   Creates a consistent snapshot by dumping the tables in a single transaction.
 
55
   During the snapshot no other connected client should use any of the
 
56
   following as this will implicitly commit the transaction and prevent the
 
57
   consistency::
 
58
 
 
59
      ALTER TABLE
 
60
      DROP TABLE
 
61
      RENAME TABLE
 
62
      TRUNCATE TABLE
 
63
 
 
64
   Only works with InnoDB.
69
65
 
70
66
.. option:: --skip-opt
71
67
 
72
 
A shortcut for :option:`--skip-drop-table`, :option:`--skip-create`, 
73
 
:option:`--skip-extended-insert` and :option:`--skip-disable-keys`
 
68
   A shortcut for :option:`--skip-drop-table`, :option:`--skip-create`, 
 
69
   :option:`--skip-extended-insert` and :option:`--skip-disable-keys`
74
70
 
75
71
.. option:: --tables t1 t2 ...
76
72
 
77
 
Dump a list of tables.
 
73
   Dump a list of tables.
78
74
 
79
75
.. option:: --show-progress-size rows (=10000)
80
76
 
81
 
Show progress of the dump every *rows* of the dump.  Requires
82
 
:option:`--verbose`
83
 
 
84
 
.. option:: --verbose, -v
85
 
 
86
 
Sends various verbose information to stderr as the dump progresses.
 
77
   Show progress of the dump every *rows* of the dump.  Requires
 
78
   :option:`--verbose`
 
79
 
 
80
.. option:: -v, --verbose
 
81
 
 
82
   Sends various verbose information to stderr as the dump progresses.
 
83
 
 
84
.. option:: --skip-create
 
85
 
 
86
   Do not dump the CREATE TABLE / CREATE DATABASE statements.
87
87
 
88
88
.. option:: --skip-extended-insert
89
89
 
90
 
Dump every row on an individual line.  For example:
91
 
 
92
 
.. code-block:: mysql
93
 
 
94
 
        INSERT INTO `t1` VALUES (1,'hello');
95
 
        INSERT INTO `t1` VALUES (2,'world');
 
90
   Dump every row on an individual line.  For example::
 
91
 
 
92
     INSERT INTO `t1` VALUES (1,'hello');
 
93
     INSERT INTO `t1` VALUES (2,'world');
96
94
 
97
95
.. option:: --skip-dump-date
98
96
 
99
 
Do not display the date/time at the end of the dump.
 
97
   Do not display the date/time at the end of the dump.
100
98
 
101
99
.. option:: --no-defaults
102
100
 
103
 
Do not attempt to read configuration from configuration files.
 
101
   Do not attempt to read configuration from configuration files.
104
102
 
105
103
.. option:: --add-drop-database
106
104
 
107
 
Add ``DROP DATABASE`` statements before ``CREATE DATABASE``.
 
105
   Add `DROP DATABASE` statements before `CREATE DATABASE`.
108
106
 
109
107
.. option:: --compact
110
108
 
111
 
Gives a more compact output by disabling header/footer comments and enabling
112
 
:option:`--skip-add-drop-table`, :option:`--skip-disable-keys` 
113
 
and :option:`--skip-add-locks`.
114
 
 
115
 
.. option:: --databases, -B
116
 
 
117
 
Dump several databases.  The databases do not need to follow on after this
118
 
option, they can be anywhere in the command line.
119
 
 
120
 
.. option:: --skip-disable-keys, -K
121
 
 
122
 
Do not dump the statements ``ALTER TABLE ... DISABLE KEYS`` and
123
 
``ALTER TABLE ... ENABLE KEYS``
 
109
   Gives a more compact output by disabling header/footer comments and enabling
 
110
   :option:`--skip-add-drop-table`, :option:`--skip-disable-keys` 
 
111
   and :option:`--skip-add-locks`.
 
112
 
 
113
.. option:: -B, --databases
 
114
 
 
115
   Dump several databases.  The databases do not need to follow on after this
 
116
   option, they can be anywhere in the command line.
 
117
 
 
118
.. option:: -K, --skip-disable-keys
 
119
 
 
120
   Do not dump the statements `ALTER TABLE ... DISABLE KEYS` and
 
121
   `ALTER TABLE ... ENABLE KEYS`
124
122
 
125
123
.. option:: --ignore-table table
126
124
 
127
 
Do not dump specified table, needs to be in the format ``database.table``.
128
 
Can be specified multiple times for multiple tables.
 
125
   Do not dump specified table, needs to be in the format `database.table`.
 
126
   Can be specified multiple times for multiple tables.
129
127
 
130
128
.. option:: --insert-ignore
131
129
 
132
 
Add the ``IGNORE`` keyword into every ``INSERT`` statement.
 
130
   Add the `IGNORE` keyword into every `INSERT` statement.
133
131
 
134
132
.. option:: --no-autocommit
135
133
 
136
 
Make the dump of each table a single transaction by wrapping it in ``COMMIT``
137
 
statements.
138
 
 
139
 
.. option:: --no-create-db, -n
140
 
 
141
 
Do not dump the ``CREATE DATABASE`` statements when using
142
 
:option:`--all-databases` or :option:`--databases`.
143
 
 
144
 
.. option:: --skip-create, -t
145
 
 
146
 
Do not dump the ``CREATE TABLE`` statements.
147
 
 
148
 
.. option:: --no-data, -d
149
 
 
150
 
Do not dump the data itself, used to dump the schemas only.
 
134
   Make the dump of each table a single transaction by wrapping it in `COMMIT`
 
135
   statements.
 
136
 
 
137
.. option:: -n, --no-create-db
 
138
 
 
139
   Do not dump the `CREATE DATABASE` statements when using
 
140
   :option:`--all-databases` or :option:`--databases`.
 
141
 
 
142
.. option:: -t, --skip-create
 
143
   
 
144
   Do not dump the `CREATE TABLE` statements.
 
145
 
 
146
.. option:: -d, --no-data
 
147
 
 
148
   Do not dump the data itself, used to dump the schemas only.
151
149
 
152
150
.. option:: --replace
153
151
 
154
 
Use ``REPLACE INTO`` statements instead of ``INSERT INTO``
 
152
   Use `REPLACE INTO` statements instead of `INSERT INTO`
155
153
 
156
154
.. option:: --destination-type type (=stdout)
157
155
 
158
 
Destination of the data.
159
 
 
160
 
**stdout**
161
 
The default.  Output to the command line
162
 
 
163
 
**database**
164
 
Connect to another database and pipe data to that.
165
 
 
166
 
.. versionadded:: 2010-09-27
 
156
   Destination of the data.
 
157
 
 
158
   **stdout**
 
159
      The default.  Output to the command line
 
160
 
 
161
   **database**
 
162
      Connect to another database and pipe data to that.
 
163
 
 
164
   .. versionadded:: 2010-09-27
167
165
 
168
166
.. option:: --destination-host hostname (=localhost)
169
167
 
170
 
The hostname for the destination database.  Requires
171
 
:option:`--destination-type` `= database`
 
168
   The hostname for the destination database.  Requires
 
169
   :option:`--destination-type` `= database`
172
170
 
173
 
.. versionadded:: 2010-09-27
 
171
   .. versionadded:: 2010-09-27
174
172
 
175
173
.. option:: --destination-port port (=3306)
176
174
 
177
 
The port number for the destination database.  Requires
178
 
:option:`--destination-type` `= database`
 
175
   The port number for the destination database.  Requires
 
176
   :option:`--destination-type` `= database`
179
177
 
180
 
.. versionadded:: 2010-09-27
 
178
  .. versionadded:: 2010-09-27
181
179
 
182
180
.. option:: --destination-user username
183
181
 
184
 
The username for the destinations database.  Requires
185
 
:option:`--destination-type` `= database`
 
182
   The username for the destinations database.  Requires
 
183
   :option:`--destination-type` `= database`
186
184
 
187
 
.. versionadded:: 2010-09-27
 
185
  .. versionadded:: 2010-09-27
188
186
 
189
187
.. option:: --destination-password password
190
188
 
191
 
The password for the destination database.  Requires
192
 
:option:`--destination-type` `= database`
 
189
   The password for the destination database.  Requires
 
190
   :option:`--destination-type` `= database`
193
191
 
194
 
.. versionadded:: 2010-09-27
 
192
  .. versionadded:: 2010-09-27
195
193
 
196
194
.. option:: --destination-database database
197
195
 
198
 
The database for the destination database, for use when only dumping a
199
 
single database.  Requires
200
 
:option:`--destination-type` `= database`
201
 
 
202
 
.. versionadded:: 2010-09-27
203
 
 
204
 
.. option:: --my-data-is-mangled
205
 
 
206
 
If your data is UTF8 but has been stored in a latin1 table using a latin1
207
 
connection then corruption is likely and drizzledump by default will retrieve
208
 
mangled data.  This is because MySQL will convert the data to UTF8 on the way
209
 
out to drizzledump and you effectively get a double-conversion to UTF8.
210
 
 
211
 
This typically happens with PHP apps that do not use ``SET NAMES``.
212
 
 
213
 
In these cases setting this option will retrieve the data as you see it in your
214
 
application.
215
 
 
216
 
.. versionadded:: 2011-01-31
217
 
 
218
 
.. option:: --host, -h hostname (=localhost)
219
 
 
220
 
The hostname of the database server.
221
 
 
222
 
.. option:: --user, -u username
223
 
 
224
 
The username for the database server.
225
 
 
226
 
.. option:: --password, -P password
227
 
 
228
 
The password for the database server.
229
 
 
230
 
.. option:: --port, -p port (=4427)
231
 
 
232
 
The port number of the database server.
 
196
   The database for the destination database, for use when only dumping a
 
197
   single database.  Requires
 
198
   :option:`--destination-type` `= database`
 
199
 
 
200
  .. versionadded:: 2010-09-27
 
201
 
 
202
.. option:: -h, --host hostname (=localhost)
 
203
 
 
204
   The hostname of the database server.
 
205
 
 
206
.. option:: -u, --user username
 
207
 
 
208
   The username for the database server.
 
209
 
 
210
.. option:: -P, --password password
 
211
 
 
212
   The password for the database server.
 
213
 
 
214
.. option:: -p, --port port (=3306,4427)
 
215
 
 
216
   The port number of the database server.  Defaults to 3306 for MySQL protocol
 
217
   and 4427 for Drizzle protocol.
233
218
 
234
219
.. option:: --protocol protocol (=mysql)
235
220
 
236
 
The protocol to use when connecting to the database server.  Options are:
237
 
 
238
 
**mysql**
239
 
The standard MySQL protocol.
240
 
 
241
 
**drizzle**
242
 
The Drizzle protocol.
 
221
   The protocol to use when connecting to the database server.  Options are:
 
222
 
 
223
   **mysql**
 
224
      The standard MySQL protocol.
 
225
 
 
226
   **drizzle**
 
227
      The Drizzle protocol.
243
228
 
244
229
Backups using Drizzledump
245
230
-------------------------
246
231
 
247
 
Backups of a database can be made very simply by running the following:
248
 
 
249
 
.. code-block:: bash
250
 
 
251
 
  $ drizzledump --all-databases > dumpfile.sql
252
 
 
253
 
This can then be re-imported into drizzle at a later date using:
254
 
 
255
 
.. code-block:: bash
256
 
 
257
 
  $ drizzle < dumpfile.sql
 
232
Backups of a database can be made very simply by running the following::
 
233
 
 
234
     $ drizzledump --all-databases > dumpfile.sql
 
235
 
 
236
This can then be re-imported into drizzle at a later date using::
 
237
 
 
238
     $ drizzle < dumpfile.sql
258
239
 
259
240
MySQL Migration using Drizzledump
260
241
---------------------------------
267
248
automatically convert all the structures and data into a Drizzle compatible 
268
249
format.
269
250
 
270
 
.. warning::
271
 
 
272
 
   :program:`drizzledump` will by default try to connect via. port 4427 so to
273
 
   connect to a MySQL server a port (such as 3306) must be specified.
274
 
 
275
251
So, simply connecting to a MySQL server with :program:`drizzledump` as follows
276
 
will give you a Drizzle compatible output:
277
 
 
278
 
.. code-block:: bash
279
 
 
280
 
  $ drizzledump --all-databases --host=mysql-host --port=3306 --user=mysql-user --password > dumpfile.sql
 
252
will give you a Drizzle compatible output::
 
253
 
 
254
     $ drizzledump --all-databases --host=mysql-host --user=mysql-user --password > dumpfile.sql
281
255
 
282
256
Additionally :program:`drizzledump` can now dump from MySQL and import directly
283
 
into a Drizzle server as follows:
284
 
 
285
 
.. code-block:: bash
286
 
 
287
 
  $ drizzledump --all-databases --host=mysql-host --port=3306 --user=mysql-user --password --destination-type=database --desination-host=drizzle-host
288
 
 
289
 
.. note::
290
 
 
291
 
   Please take special note of :ref:`old-passwords-label` if you have connection
292
 
   issues from :program:`drizzledump` to your MySQL server.
293
 
 
294
 
.. note::
295
 
   If you find your VARCHAR and TEXT data does not look correct in a drizzledump
296
 
   output, it is likely that you have UTF8 data stored in a non-UTF8 table.  In
297
 
   which case please check the :option:`--my-data-is-mangled` option.
 
257
into a Drizzle server as follows::
 
258
 
 
259
     $ drizzledump --all-databases --host=mysql-host --user=mysql-user --password --destination-type=database --desination-host=drizzle-host
298
260
 
299
261
When you migrate from MySQL to Drizzle, the following conversions are required:
300
262
 
301
 
 * MyISAM -> InnoDB
302
 
 * FullText -> drop it (with stderr warning)
303
 
 * int unsigned -> bigint
304
 
 * tinyint -> int
305
 
 * smallint -> int
306
 
 * mediumint -> int
307
 
 * tinytext -> text
308
 
 * mediumtext -> text
309
 
 * longtext -> text
310
 
 * tinyblob -> blob
311
 
 * mediumblob -> blob
312
 
 * longblob -> blob
313
 
 * year -> int
314
 
 * set -> text [1]_
315
 
 * date/datetime default 0000-00-00 -> default NULL [2]_
316
 
 * date/datetime NOT NULL columns -> NULL [2]_
317
 
 * any date data containing 0000-00-00 -> NULL [2]_
318
 
 * time -> int of the number of seconds [3]_
319
 
 * enum-> DEFAULT NULL [4]_
320
 
 
321
 
.. rubric:: Footnotes
322
 
 
323
 
.. [1] There is currently no good alternative to SET, this is simply to preserve
324
 
       the data in the column.  There is a new alternative to SET to be included
325
 
       at a later date.
326
 
 
327
 
.. [2] Currently, ALL date columns have their DEFAULT set to NULL on migration.
328
 
       This is so that any rows with 0000-00-00 dates can convert to NULL.
329
 
 
330
 
.. [3] This prevents data loss since MySQL's TIME data type has a range of
331
 
       -838:59:59 - 838:59:59, and Drizzle's TIME type has a range of
332
 
       00:00:00 - 23:59:59.
333
 
 
334
 
.. [4] This is so that empty entries such as '' will convert to NULL.
 
263
MyISAM -> InnoDB
 
264
FullText -> drop it (with stderr warning)
 
265
int unsigned -> bigint
 
266
tinyint -> int
 
267
smallint -> int
 
268
mediumint -> int
 
269
tinytext -> text
 
270
mediumtext -> text
 
271
longtext -> text
 
272
tinyblob -> blob
 
273
mediumblob -> blob
 
274
longblob -> blob
 
275
time -> int (of seconds)
 
276
year -> int
 
277
set -> text
 
278
date/datetime default 0000-00-00 -> default NULL *(Currently, ALL date columns have their DEFAULT set to NULL on migration)
 
279
date/datetime NOT NULL columns -> NULL
 
280
any date data containing 0000-00-00 -> NULL
 
281
enum-> DEFAULT NULL
 
 
b'\\ No newline at end of file'