Home > database >  Excuse me, MySQL database can set a single user mode?
Excuse me, MySQL database can set a single user mode?

Time:09-16

Excuse me, MySQL database can set a single user mode?
Is a only a USER or connection to access the database, as used in MULTI USER and SINGLE USER mode,

CodePudding user response:

A user, you can directly set user permissions, if multiple users, is the current can only connect one that don't know how to do

CodePudding user response:

Max_connections is set to 1, so only allow a connection to connect to the database

 
- session1
mysql> Show variables like 'max_connections';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
200 | | max_connections |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
1 row in the set, 1 warning (0.00 SEC)

mysql> The set global max_connections=1;
Query OK, 0 rows affected (0.00 SEC)

mysql>
mysql> Show variables like 'max_connections';
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
Value | | Variable_name |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
| | max_connections | 1
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- +
1 row in the set, 1 warning (0.00 SEC)

- the session 2
C: \ & gt; Mysql - uroot - p
Enter password: * * * * * *
ERROR 1040 (HY000) : Too many connections

CodePudding user response:

Pro, I mean access to the specified database can only have a connection, such as the database connection DB_XXX, only one connection, you modify the number of connections is the server can only be a connection,

CodePudding user response:

reference sanesoft reply: 3/f
, I mean access to the specified database can only have a connection, such as the database connection DB_XXX, only one connection, you can only modify the number of connections is the server a connection,


Mysql resource limit parameter is directed at the instance level, rather than a database level

If you do so, can provide a train of thought, first only allow a user, for example 'my_user' @ 'IP' the user access DB_XXX, through access control

If the same user control multiple connections, through the audit init - connect software, will land on the log entry to the entity list, through the trigger to write logic implementation,

  • Related