~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/clients/drizzledump.rst

Fix pidfile argument.

Show diffs side-by-side

added added

removed removed

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