In MySQL 8 installations on Ubuntu, both directories serve as include locations for configuration files:
/etc/mysql/conf.d/ # For user/administrator configurations
/etc/mysql/mysql.conf.d/ # For package-maintained configurations
The main distinction lies in their management:
- mysql.conf.d/: Maintained by MySQL packages (deb/rpm). Contains critical files:
mysqld.cnf # Main server configuration mysql.cnf # Client configuration mysqldump.cnf # Dump utility configuration
- conf.d/: Intended for custom configurations. Empty by default.
Files are loaded alphabetically from both directories. Later settings override earlier ones. Example loading sequence:
1. /etc/mysql/mysql.conf.d/mysqld.cnf
2. /etc/mysql/conf.d/custom.cnf
For custom configurations:
- Always use
/etc/mysql/conf.d/
for your changes - Create separate files for logical groupings:
# Recommended naming convention custom-optimization.cnf custom-replication.cnf
- Never modify files in
mysql.conf.d/
directly
Instead of editing mysqld.cnf
, create:
# /etc/mysql/conf.d/buffer-pool.cnf
[mysqld]
innodb_buffer_pool_size = 4G
To verify loaded configurations:
mysql --help --verbose | grep -A 10 "Default options"
# Or check the effective configuration:
SELECT * FROM performance_schema.variables_by_thread
WHERE VARIABLE_NAME LIKE '%buffer%';
The separation serves important purposes:
- Prevents package upgrades from overwriting custom configs
- Maintains clean distinction between system and user settings
- Enables safer configuration management
When working with MySQL 8 on Ubuntu, you'll notice two configuration directories:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
The mysql.conf.d/
directory is typically managed by the MySQL package maintainers. This is where the distribution stores its default configuration files, including:
mysql.cnf
mysqld.cnf
On the other hand, conf.d/
is designed for user-specific configurations and is the recommended location for your custom configurations.
For your own configuration files, you should use /etc/mysql/conf.d/
. This ensures:
- Your configurations won't be overwritten during package upgrades
- Clear separation between system and custom configurations
- Better maintainability when troubleshooting
MySQL processes files in alphanumeric order within each directory. Files in mysql.conf.d/
typically load first (starting with 'm'), followed by conf.d/
files. You can verify this with:
mysql --help | grep "Default options"
To add a custom buffer pool size configuration:
# Create a new config file in the proper directory
sudo nano /etc/mysql/conf.d/custom.cnf
# Add your custom settings
[mysqld]
innodb_buffer_pool_size = 4G
# Restart MySQL to apply changes
sudo systemctl restart mysql
If you encounter problems, check the loading order and potential conflicts:
sudo mysqld --verbose --help | grep -A 1 "Default options"
Remember that later configurations override earlier ones with the same parameters.