How to use mysqltuner with EE4

mysqltuner is a perl script that helps you to tune your mysql server’s configuration. This post will cover how to run it on EasyEngine v4.

The following command will install and run mysqltuner on the global database container.

cd /opt/easyengine/services && docker-compose exec global-db bash -c '
apt update
apt install wget mysqltuner -y
wget -O basic_passwords.txt
wget -O vulnerabilities.csv
mysqltuner --user root --pass ${MYSQL_ROOT_PASSWORD} --cvefile=vulnerabilities.csv --passwordfile=basic_passwords.txt'

If you have already installed it and just want to run it, then run following command:

cd /opt/easyengine/services && docker-compose exec global-db bash -c 'mysqltuner --user root --pass ${MYSQL_ROOT_PASSWORD} --cvefile=vulnerabilities.csv'

If you have created sites with local db container, you need to run the command on it manually. To find all db containers on a machine, run:

docker ps -f 'label=org.label-schema.vendor=EasyEngine' -f ''

You can automate running above commands on all containers with following one liner:

docker ps -f 'label=org.label-schema.vendor=EasyEngine' -f '' | xargs -I{} docker exec {} <command>

These commands will give run mysqltuner on your containers. Based on the output of mysqltuner, you’ll have to tune configuration of mysql. Location of global mysql’s config is mentioned in services filesystem documentation and location of site’s local db is mentioned in site’s filesystem documentation.

If you don’t have much experience with mysqltuner and would like a primer on it, you can read this article.