MySQL Database Optimization

For details on how to configure Traccar to work with MySQL database please check MySQL config.

Default MySQL configuration might be enough for a small setup, but if you have a large number of devices and/or high frequency of location reporting, you might want to adjust the database configuration. Optimal parameters depend on many factors, so following are just our preferences when running Traccar on DigitalOcean VPS servers with Ubuntu operating system.

Add custom configuration file:

nano /etc/mysql/mysql.conf.d/custom.cnf

An example for a server with 3GB of RAM:

[mysqld]
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 0

Restart MySQL service and Traccar service for new parameters to take effect:

sudo systemctl stop traccar
sudo systemctl restart mysql
sudo systemctl start traccar