MySQL offers a changeUser command that allows you to alter the current user and other aspects of the connection without shutting down the underlying socket:
connection.changeUser({user : 'john'}, function(err) {
if (err) throw err;
});
The available options for this feature are:
user: The name of the new user (defaults to the previous one).
password: The password of the new user (defaults to the previous one).
charset: The new charset (defaults to the previous one).
database: The new database (defaults to the previous one).
创建两个连接不行吗?
@carlisliu 就是创建两个实例吧
@DominicHjj 是的,
类似这样,一个connection操作一个库
MySQL offers a changeUser command that allows you to alter the current user and other aspects of the connection without shutting down the underlying socket:
The available options for this feature are:
user: The name of the new user (defaults to the previous one). password: The password of the new user (defaults to the previous one). charset: The new charset (defaults to the previous one). database: The new database (defaults to the previous one).