Systeemvariabelen (MySQL)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Systeemvariabelen kun je bewerken in scripts, maar ook interactief.

Uitlezen

Voorbeelden hoe je MySQL systeemvariabelen kunt uitlezen:

show variables;

show variables where Variable_name like "%sort%";

show variables where Variable_name like "%sort\_buffer\_size%";

Indien waardes geheugenhoeveelheden betreft, zijn dit vermoedelijk waardes in bytes. Voorbeeld:

> mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.22-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables where Variable_name like "%sort\_buffer\_size%";
+-------------------------+---------+
| Variable_name           | Value   |
+-------------------------+---------+
| innodb_sort_buffer_size | 1048576 |
| myisam_sort_buffer_size | 8388608 |
| sort_buffer_size        | 262144  |
+-------------------------+---------+
3 rows in set (0.00 sec)

De eerste waarde is namelijk 2^20 en dat is traditioneel het aantal bytes in een megabyte

Schrijven

Voorbeeld:

show 
   variables 
where 
   Variable_name like "%sort\_buffer\_size%";

set 
   sort_buffer_size = 524288;

show 
   variables 
where 
   Variable_name like "%sort\_buffer\_size%";

Zie ook