Du kan bruge INFORMATION_SCHEMA GLOBAL_VARIABLES
og SESSION_VARIABLES
tabeller
sådan her:
SELECT *
FROM information_schema.global_variables
WHERE variable_name LIKE '%version%';
Eksempeloutput:
| VARIABLE_NAME | VARIABLE_VALUE | |-------------------------|--------------------------------------| | INNODB_VERSION | 5.5.32 | | PROTOCOL_VERSION | 10 | | VERSION_COMMENT | MySQL Community Server (GPL) by Remi | | VERSION | 5.5.32 | | VERSION_COMPILE_MACHINE | x86_64 | | VERSION_COMPILE_OS | Linux | | SLAVE_TYPE_CONVERSIONS | |
Her er SQL Fiddle demo.
OPDATERING (baseret på dine kommentarer)
Du kan angive alle variabelnavne, du har brug for, med IN
klausul
SELECT *
FROM information_schema.global_variables
WHERE variable_name IN ('version', 'hostname', 'port');
Eksempeloutput:
| VARIABLE_NAME | VARIABLE_VALUE | |---------------|----------------| | VERSION | 5.5.32 | | HOSTNAME | db2 | | PORT | 3306 |
Her er SQL Fiddle demo.