File tree 1 file changed +24
-0
lines changed 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,30 @@ connection.destroy();
184
184
185
185
Unlike ` end() ` the ` destroy() ` method does not take a callback argument.
186
186
187
+ ## Switching users / altering connection state
188
+
189
+ MySQL offers a changeUser command that allows you to alter the current user and
190
+ other aspects of the connection without shutting down the underlaying socket:
191
+
192
+ ``` js
193
+ connection .changeUser ({user : ' john' }, function (err ) {
194
+ if (err) throw err;
195
+ });
196
+ ```
197
+
198
+ The available options for this feature are:
199
+
200
+ * ` user ` : The name of the new user (defaults to the previous one).
201
+ * ` password ` : The password of the new user (defaults to the previous one).
202
+ * ` charset ` : The new charset (defaults to the previous one).
203
+ * ` database ` : The new database (defaults to the previous one).
204
+
205
+ A sometimes useful side effect of this functionality is that this function also
206
+ resets any connection state (variables, transactions, etc.).
207
+
208
+ Errors encountered during this operation are treated as fatal connection errors
209
+ by this module.
210
+
187
211
## Server disconnects
188
212
189
213
You may loose the connection to a MySQL server due to network problems, the
You can’t perform that action at this time.
0 commit comments