Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of two methods of setting global variable and session variable by MySQL

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. To modify global variables in MySQL, there are two ways:

Method 1: Modify the my.ini configuration file. If you want to set global variables, the easiest way is to write the variable configuration directly in the my.ini file, as shown in the following figure. Restart the database service to make global variables effective.

We open a few mysql command lines, you can see that all the variables in the session are in effect, as shown in the figure

Method 2: On the basis of not modifying the configuration file, use the keyword global to set global variables.

set global autocommit=1;

Set the value of the autocommit variable to ON

Note that setting the global variable using this method is valid only for newly opened sessions, not for sessions that are already open.

2. To modify session variables in MySQL, you can use the session keyword, such as:

set session autocommit=1;

Modify session variable configuration, only valid for this session variable configuration, invalid for other sessions.

Although global variables and session variables are set, after the MySQL service restarts, the database configuration will be reinitialized, and everything will be initialized according to the configuration of my.ini. Both global and session configurations are disabled.

summary

The above is the MySQL global variable and session variable method introduced to you by Xiaobian. I hope it will help you. If you have any questions, please leave a message to me. Xiaobian will reply to you in time. Thank you very much for your support!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report