EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB wait_timeout
Secondary Sidebar
MariaDB Tutorial
  • MariaDB
    • MariaDB Versions
    • MariaDB? list users
    • MariaDB Commands
    • MariaDB odbc
    • MariaDB Workbench
    • MariaDB for windows
    • MariaDB Server
    • MariaDB? Data Types
    • MariaDB? boolean
    • MariaDB phpMyAdmin
    • MariaDB Mysqldump
    • MariaDB Java Connector
    • MariaDB insert
    • MariaDB UPDATE
    • MariaDB? rename column
    • MariaDB AUTO_INCREMENT
    • MariaDB Timezone
    • MariaDB GROUP_CONCAT
    • MariaDB wait_timeout
    • MariaDB MaxScale
    • MariaDB? with
    • MariaDB GUI
    • MariaDB? create?table
    • MariaDB? SHOW TABLES
    • MariaDB alter table
    • MariaDB List Tables
    • MariaDB JSON Functions
    • MariaDB Foreign Key
    • MariaDB? trigger
    • MariaDB Grant All Privileges
    • MariaDB Select Database
    • MariaDB? create database
    • MariaDB Delete Database
    • MariaDB Join
    • MariaDB JSON
    • MariaDB? show databases
    • MariaDB List Databases
    • MariaDB Functions
    • MariaDB? TIMESTAMP
    • MariaDB create user
    • MariaDB add user
    • MariaDB Max Connections
    • MariaDB show users
    • MariaDB Delete User
    • MariaDB? change user password
    • MariaDB? change root password
    • MariaDB reset root password
    • MariaDB IF
    • MariaDB bind-address
    • MariaDB Transaction
    • MariaDB Cluster
    • MariaDB Logs
    • MariaDB Encryption
    • MariaDB? backup
    • MariaDB Replication
    • MariaDB max_allowed_packet
    • MariaDB? performance tuning
    • MariaDB export database
    • MariaDB? import SQL

MariaDB wait_timeout

By Aanchal SharmaAanchal Sharma

MariaDB wait_timeout

Definition of MariaDB wait_timeout Function

MariaDB wait_timeout function is defined as a task of the server where it waits for a number of seconds for any action on a no collaborating connection beforehand closing it. This wait_timeout function works as a system variable with global as well as session scopes. MariaDB wait_timeout function is a dynamic variable in the server which is of integer type with default value as 28800 and without SET_VAR Hint Applies. Also, the wait_timeout function has a minimum value 1, the maximum value for other as 31536000, and maximum value for Windows as 2147483 and it has the command line format written as –wait_timeout=#.

Syntax:

Let us discuss the usage with syntax of MariaDB wait_timeout function as follows:

This wait_timeout function represents a system variable that can be set within a configuration file as:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,818 ratings)

[mariadb] Wait_timeout=130;

The global value of this MariaDB system variable wait_timeout also can be dynamically set at runtime by running the query with keyword SET GLOBAL written as below:

SET GLOBAL wait_timeout =130;

The session value of this MariaDB system variable wait_timeout also can be dynamically set at runtime by running the query with keyword SET SESSION written as below:

SET SESSION wait_timeout =130;

But if the value of system variable wait_timeout is set at runtime dynamically then the value may be reset the next time whenever we restart the server. We can make the value of the function wait_timeout to persist on the server restart, by setting it in a configuration file excessively.

How wait_timeout function works in MariaDB?

As MariaDB wait_timeout function has global scope and session also so, on the thread startup, either from the value of global interactive_timeout function or from the value of global wait_timeout function, the value of session wait_timeout is prepared on the basis of the kind of client which may be stated by the CLIENT_INTERACTIVE associate option to mysql_real_connect().

In detail, the MariaDB wait_timeout function which is a system variable is responsible to set the time in seconds which the server is waiting for an indolent collaborating connection for becoming active before terminating it.

The MariaDB system variable wait_timeout function needs the SUPER privilege on the server to set the value of its global scope dynamically at runtime.

Examples

Let us view the effect of the Interactive_timeout and MariaDB wait_timeout function working in the server:

The MariaDB system variable interactive_timeout function purposes by overriding the value of the MariaDB system variable wait_timeout function for building up interactive connections. Suppose, we can illustrate this by using the interactive_timeout function and wait_timeout function settings to diverse values as shown below:

SET GLOBAL interactive_timeout=90;
SET GLOBAL wait_timeout =60;

Output:

MariaDB wait_timeout 1

Within this structure, when a user associates to the server along with an interactive client, at the time the user will view that their system variable wait_timeout’s session value is essentially set to the interactive_timeout’s global value.

By default, the MySQL command-line client works as an interactive client therefore this client may be implemented to determine the behavior of this interactive clients as follows:

$ sudo mysql
SHOW SESSION VARIABLES LIKE 'wait_timeout';

Output:

MariaDB wait_timeout 2

Nevertheless, the MySQL server command line client works as a non-interactive client when the option –batch is delivered, thus this client now will be applied with this possibility to determine the behavior of non-interactive clients:

$sudo mysql -- batch --execute =”SHOW SESSION VARIABLES LIKE ‘wait_timeout’”
Variable_name Value
Wait_timeout 30

Canceled Connections

If any connection has been idle for a lengthier time than the configured system variable wait_timeout value, then the server may eradicate the connection. But if the system variable log_warnings is set or configured to 2 or more, thereafter a warning along with the error code as ER_ABORTING_CONNECTION may be displayed to the respective error log or its file as shown below:

MariaDB wait_timeout 3

We can also reset the Global value of wait_timeout function dynamically to default by just adding the keyword DEFAULT as below:

SET GLOBAL wait_timeout=150;
SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

Output:

MariaDB wait_timeout 4

SET GLOBAL wait_timeout=DEFAULT;
SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

Output:

MariaDB wait_timeout 5

We can also perform reset to the value of session to the value of Global for wait_timeout function similarly by setting to DEFAULT as:

SET SESSION wait_timeout=150;
SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

Output:

MariaDB wait_timeout 6

SHOW SESSION VARIABLES LIKE 'wait_timeout';

Output:

 MariaDB wait_timeout 7

SET SESSION wait_timeout=DEFAULT;
SHOW SESSION VARIABLES LIKE 'wait_timeout';

Output:

example

Invalid system variable value:

When the MariaDB system variable wait_timeout function value is provided to an invalid one by any user then, the particular behavior be influenced by the system variable sql_mode value. But if this sql_mode variable in MariaDB does not include STRICT_ALL_TABLES and also if a user effort to place an invalid value to the wait_timeout function then, this execution of operation query will succeed and at the same time a warning will also be delivered with the error code ER_TRUNCATED_WRONG_VALUE.

Thus, this warning defines that the value was abbreviated which states that the value set was spontaneous to the contiguous inacceptable value as below:

SET GLOBAL wait_timeout=-1;
SHOW WARNINGS;

Output:

return value

SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

Output:

show Query box 2

SET GLOBAL wait_timeout=305350100;
SHOW WARNINGS;

Output:

error

SHOW GLOBAL VARIABLES LIKE 'wait_timeout';

 Output:

show Query box 1

If this sql_mode variable in MariaDB includes STRICT_ALL_TABLES and also if a user effort to place an invalid value to the wait_timeout function then, this execution of operation query will succeed and at the same time a warning will also be delivered with the error code ER_WRONG_VALUE_FOR_VAR as:

SHOW SESSION VARIABLES LIKE 'sql_mode';

Output:

 show Query box

Invalid variable type:

Suppose any user attempts to make the wait_timeout function to an invalid argument value then this operation will be failed generating an error code as ER_WRONG_TYPE_FOR_VAR as:

SET GLOBAL wait_timeout=' ';

Output:

set globle

SET GLOBAL wait_timeout='infinity';

Output:

example 1

Conclusion

MySQL and MariaDB databases include various timeout variable functions which are useful for controlling and managing the serve operations. The wait_timeout function in MariaDB refers to the number of seconds that the server is waiting for any task or operation on an established connection before it gets closed. Hence, the function works dynamically and supports the configuration file with data type BIGINT UNSIGNED.

Recommended Articles

This is a guide to MariaDB wait_timeout. Here we discuss the Definition, How wait_timeout function works in MariaDB? and examples with code implementation. You may also have a look at the following articles to learn more –

  1. MariaDB MaxScale
  2. MariaDB UPDATE
  3. MariaDB Foreign Key
  4. MariaDB Commands
Popular Course in this category
SQL Training Program (7 Courses, 8+ Projects)
  7 Online Courses |  8 Hands-on Projects |  73+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more