> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rocky.global/llms.txt
> Use this file to discover all available pages before exploring further.

# MYSQL RAM OPTIMIZATION

# MySQL Server RAM Optimization

Recommended server-side configuration to reduce MySQL memory usage. Adjust these in `my.cnf` (or equivalent) and restart MySQL.

## InnoDB

```ini theme={null}
# Use 50-70% of dedicated DB server RAM; reduce on shared hosts
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 16M
```

## Connections

```ini theme={null}
# Lower than default 151 if you do not need many concurrent connections
max_connections = 50
```

## Query / temporary tables

```ini theme={null}
tmp_table_size = 32M
max_heap_table_size = 32M
join_buffer_size = 256K
sort_buffer_size = 256K
```

## Query cache (MySQL 8+)

Query cache is removed in MySQL 8. If you are on MySQL 5.7 and use it, disable to avoid overhead:

```ini theme={null}
query_cache_type = 0
```

## Applying

* **Linux**: Often `/etc/mysql/my.cnf` or `/etc/my.cnf`
* **macOS (Homebrew)**: `$(brew --prefix mysql)/etc/my.cnf`
* Restart MySQL after changes.
