How to Set Access Whitelist in TiDB

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB如何设置访问白名单

| username: TiDBer_7Oi7Om69

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
tidb 6.1.1
As the title suggests, how to set up an access whitelist for the cluster?

| username: hey-hoho | Original post link

Are you referring to a whitelist for SQL users? Can this type of host restriction for login users be done like this:

CREATE USER `rw_user`@`192.168.%`;
| username: TiDBer_7Oi7Om69 | Original post link

This is for setting a whitelist for a single user. There is a problem here, which is how to set multiple IPs, such as company and home IPs, without using wildcards.
Apart from setting it for a single user, I want to see if there is a way to set a whitelist for cluster access directly, so that IPs outside the whitelist are not allowed to make requests at all.

| username: hey-hoho | Original post link

This suggestion should be implemented in Load Balance. According to the official website, the enterprise edition has this feature:

| username: TiDBer_7Oi7Om69 | Original post link

Okay, got it, need the enterprise edition :joy:

| username: TiDBer_7Oi7Om69 | Original post link

Can multiple IPs be filled in for a single user host restriction?

| username: 裤衩儿飞上天 | Original post link

The enterprise edition has this feature.

| username: hey-hoho | Original post link

The host cannot have multiple IPs. You can do something like this:

CREATE USER `rw_user`@`192.168.1.1` IDENTIFIED BY '111111';
CREATE USER `rw_user`@`192.168.1.2` IDENTIFIED BY '111111';
| username: hey-hoho | Original post link

Opening a firewall whitelist on the load balance node is also an option.

| username: forever | Original post link

Each IP has one account, but the account passwords are all the same.