> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# SET

> Sets the specified system variables or user-defined variables for the database.

Sets the specified system variables or user-defined variables for the database. You can view the system variables of the database using [SHOW VARIABLES](/documents/4.2/sql-reference/sql-statements/cluster-management/config_vars/SHOW_VARIABLES.md). For details about system variables, see [System Variables](/documents/4.2/sql-reference/System_variable.md). For details about user-defined variables, see [User-defined variables](/documents/4.2/sql-reference/user_defined_variables.md).

**Tip**

This operation does not require privileges.

## Syntax

```SQL theme={null}
SET [ GLOBAL | SESSION ] <variable_name> = <value> [, <variable_name> = <value>] ...
```

## Parameters

| **Parameter** | **Description** |
| - | - |
| Modifier:<ul><li>GLOBAL</li><li>SESSION</li></ul> | <ul><li>With a `GLOBAL` modifier, the statement sets the variables globally.</li><li>With a `SESSION` modifier, the statement sets the variables within the session. `LOCAL` is a synonym for `SESSION`.</li><li>If no modifier is present, the default is `SESSION`.</li></ul>For details about global and session variables, see [System Variables](/documents/4.2/sql-reference/System_variable.md). **NOTE** Only users with the ADMIN privilege can set the variables globally. |
| variable\_name | The name of the variable. |
| value | The value of the variable. |

## Examples

Example 1: Set the `time_zone` to `Asia/Shanghai` within the session.

```Plain theme={null}
mysql> SET time_zone = "Asia/Shanghai";
Query OK, 0 rows affected (0.00 sec)
```

Example 2: Set the `query_mem_limit` to `2147483648` globally.

```Plain theme={null}
mysql> SET GLOBAL query_mem_limit = 2147483648;
Query OK, 0 rows affected (0.00 sec)
```

Example 3: Set multiple global variables. Add the `GLOBAL` keyword before each variable.

```Plain theme={null}
mysql> SET 
       GLOBAL query_mem_limit = 2147483648,
       GLOBAL time_zone = "Asia/Shanghai";
Query OK, 0 rows affected (0.00 sec)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.