Where to find tidb.toml and update it

in System Variables | PingCAP Docs
“To retain any values set, you need to specify the variables in your tidb.toml configuration file.”

I have changed system variable “tidb_tmp_table_max_size” from default 64M to 512M via mysql client:

mysql> set global tidb_tmp_table_max_size=512*1024*1024;
Query OK, 0 rows affected (0.04 sec)

where to find tidb.toml and modify it, so when restart tidb cluster, “tidb_tmp_table_max_size” will set to 512M automatically ?

To update the tidb_tmp_table_max_size system variable in the tidb.toml configuration file, you can follow these steps:

  1. Locate the tidb.toml configuration file:

    • The tidb.toml configuration file is typically located in the conf directory of your TiDB deployment.
    • If you are using TiUP to manage your TiDB cluster, you can find the tidb.toml configuration file in the directory where you deployed the cluster.
  2. Open the tidb.toml configuration file in a text editor.

  3. Find the section related to TiDB configuration in the tidb.toml file. It should look similar to the following:

    [tidb]
    # Other TiDB configuration options...
    
  4. Add or update the tidb_tmp_table_max_size variable in the tidb section with the desired value (512M in this case). The configuration should look like this:

    [tidb]
    tidb_tmp_table_max_size = 536870912
    
  5. Save the changes to the tidb.toml file.

  6. After updating the tidb.toml file, you need to apply the changes to the TiDB cluster by reloading the configuration. You can use the tiup cluster reload command to achieve this. For example:

    tiup cluster reload ${cluster-name} -R tidb
    

By following these steps, the tidb_tmp_table_max_size system variable will be set to 512M automatically when you restart the TiDB cluster. This ensures that your desired configuration is retained across cluster restarts.

how about

  1. tiup cluster edit-config tidb-test
    and change
server_configs:
  tidb: {}

to

server_configs:
  tidb:
    tidb_tmp_table_max_size: 536870912
  1. use tiup cluster reload tidb-test [-N <nodes>] [-R <roles>] to reload config

Yes, you can also update the tidb_tmp_table_max_size system variable directly in the TiUP cluster configuration using the tiup cluster edit-config command. Here's how you can do it:

  1. Run the following command to edit the configuration of the tidb-test cluster:

    tiup cluster edit-config tidb-test

    Then, modify the configuration to set the tidb_tmp_table_max_size variable to 512M as follows:

    server_configs:
      tidb:
        tidb_tmp_table_max_size: 536870912
    

    Save the changes to the configuration file.

  2. After updating the configuration, you can use the tiup cluster reload command to apply the changes to the TiDB cluster. The command should look like this:

    tiup cluster reload tidb-test -R tidb

    This command will reload the configuration for the TiDB component in the tidb-test cluster, ensuring that the tidb_tmp_table_max_size variable is set to 512M as specified in the configuration file.

By following these steps, you can update the system variable directly in the TiUP cluster configuration and apply the changes to the TiDB cluster using the tiup cluster reload command.