@@ -272,15 +272,26 @@ Yields:
272
272
next_result: Unknown column 'A' in 'field list' (Mysql2::Error)
273
273
```
274
274
275
- See https://gist.github.com/1367987 for using MULTI_STATEMENTS with Active Record.
276
-
277
275
### Secure auth
278
276
279
277
Starting wih MySQL 5.6.5, secure_auth is enabled by default on servers (it was disabled by default prior to this).
280
278
When secure_auth is enabled, the server will refuse a connection if the account password is stored in old pre-MySQL 4.1 format.
281
279
The MySQL 5.6.5 client library may also refuse to attempt a connection if provided an older format password.
282
- To bypass this restriction in the client, pass the option : secure_auth => false to Mysql2::Client.new().
283
- If using ActiveRecord, your database.yml might look something like this:
280
+ To bypass this restriction in the client, pass the option ` :secure_auth => false ` to Mysql2::Client.new().
281
+
282
+ ### Flags option parsing
283
+
284
+ The ` :flags ` parameter accepts an integer, a string, or an array. The integer
285
+ form allows the client to assemble flags from constants defined under
286
+ ` Mysql2::Client ` such as ` Mysql2::Client::FOUND_ROWS ` . Use a bitwise ` | ` (OR)
287
+ to specify several flags.
288
+
289
+ The string form will be split on whitespace and parsed as with the array form:
290
+ Plain flags are added to the default flags, while flags prefixed with ` - `
291
+ (minus) are removed from the default flags.
292
+
293
+ This allows easier use with ActiveRecord's database.yml, avoiding the need for magic flag numbers.
294
+ For example, to disable protocol compression, and enable multiple statements and result sets:
284
295
285
296
``` yaml
286
297
development :
@@ -291,21 +302,25 @@ development:
291
302
password : my_password
292
303
host : 127.0.0.1
293
304
port : 3306
305
+ flags :
306
+ - -COMPRESS
307
+ - FOUND_ROWS
308
+ - MULTI_STATEMENTS
294
309
secure_auth : false
295
310
` ` `
296
311
297
312
### Reading a MySQL config file
298
313
299
314
You may read configuration options from a MySQL configuration file by passing
300
- the ` :default_file` and `:default_group` paramters . For example:
315
+ the ` :default_file` and `:default_group` parameters . For example:
301
316
302
317
` ` ` ruby
303
318
Mysql2::Client.new(:default_file => '/user/.my.cnf', :default_group => 'client')
304
319
` ` `
305
320
306
321
# ## Initial command on connect and reconnect
307
322
308
- If you specify the init_command option, the SQL string you provide will be executed after the connection is established.
323
+ If you specify the `: init_command` option, the SQL string you provide will be executed after the connection is established.
309
324
If `:reconnect` is set to `true`, init_command will also be executed after a successful reconnect.
310
325
It is useful if you want to provide session options which survive reconnection.
311
326
0 commit comments