In MySQL's evolution, both key_buffer
and key_buffer_size
have been used, creating confusion for DBAs and developers. The official MySQL documentation confirms that key_buffer_size
is the current standard parameter since MySQL 4.0, while key_buffer
remains as a deprecated alias for backward compatibility.
For modern MySQL installations (5.5+), you should exclusively use:
[mysqld]
key_buffer_size = 256M
The [isamchk]
section should also be updated:
[isamchk]
key_buffer_size = 128M
To check which parameter your MySQL instance is actually using:
SHOW VARIABLES LIKE 'key_buffer%';
Or through command line:
mysqladmin variables | grep key_buffer
Here's a complete my.cnf
snippet for a production server with 8GB RAM:
[mysqld]
key_buffer_size = 1G
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
[isamchk]
key_buffer_size = 512M
The key buffer size should typically be set to 20-25% of available memory for dedicated MySQL servers. For a server with 16GB RAM:
key_buffer_size = 4G
But monitor actual usage with:
SHOW STATUS LIKE 'Key%';
While key_buffer
still works in current versions, it was officially marked as deprecated in MySQL 5.0 and may be removed in future releases. The MySQL 8.0 documentation no longer mentions the key_buffer
alias.
In MySQL's evolution, both key_buffer
and key_buffer_size
have existed in various versions. The confusion stems from:
- MySQL 4.0 and earlier:
key_buffer
was the primary parameter - MySQL 4.1+:
key_buffer_size
became the standard name - Modern MySQL (5.0+):
key_buffer_size
is the officially documented parameter
For Ubuntu 12.04 with default MySQL packages, you should use:
[mysqld]
key_buffer_size = 256M # For modern MySQL installations
[isamchk]
key_buffer = 16M # For ISAM table maintenance
The distinction matters because:
mysqld
section should usekey_buffer_size
for MyISAM index cachingisamchk
section maintains backward compatibility withkey_buffer
To check which parameter your MySQL server recognizes:
mysql> SHOW VARIABLES LIKE 'key_buffer%';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| key_buffer_size | 268435456 |
+-----------------+-----------+
If you're upgrading from older MySQL versions:
# Before upgrading:
[mysqld]
key_buffer = 16M
# After upgrading to MySQL 5.0+:
[mysqld]
key_buffer_size = 16M
Modern MySQL versions will accept key_buffer
for backward compatibility but will treat it as key_buffer_size
internally.
The key buffer size should typically be:
- 20-25% of available RAM for dedicated MySQL servers
- No more than 4G for 32-bit systems
- Adjustable based on your MyISAM index usage