MySQL - RESET PERSIST Statement



MySQL RESET PERSIST Statement

You can remove a global variable from MySQL server using the RESET PERSIST statement. Once you delete a variable using this statement it is no longer available in the mysqld-auto.cnf file. To remove dynamic system variables using this statement you need the SYSTEM_VARIABLES_ADMIN privilege and to remove the read-only system variables you need PERSIST_RO_VARIABLES_ADMIN privilege too.

Syntax

Following is the syntax of the MySQL RESET PERSIST statement.

RESET PERSIST [[IF EXISTS] system_var_name]

Where, is the system_var_name name of the global variable you need to delete.

Example

The SET statement in MySQL is used to assign values for variables. Using this you let us set a persist variable as −

SET PERSIST max_relay_log_size = 12;

SET @@PERSIST.max_relay_log_size = 12;

Following statement deletes the above created global variable from the mysqld-auto.cnf file −

RESET PERSIST max_relay_log_size;

Removing all persist variables

If you execute the RESET PERSIST variable without specifying any variable all the variables from the mysqld-auto.cnf will be deleted.

RESET PERSIST;

The IF EXISTS clause

If you try to remove a global variable from the mysqld-auto.cnf that doesn’t exist, an error will be generated as shown below −

RESET PERSIST max_relay_log_size;
ERROR 3615 (HY000): Variable max_relay_log_size does not 
exist in persisted config file

If you use the IF EXISTS clause along with the RESET PERSIST statement as shown below, the specified variable will be dropped and if a variable with the given name, doesn’t exist the query will be ignored.

DROP TABLE IF EXISTS max_relay_log_size;
Advertisements