Running a second MySQL instance on your server
Sometimes you are using MySQL 5.7 for your main project but now you need to run another project on the same server that uses MySQL 8.0. In this case you can choose to run MySQL using docker.
Please be aware that our default MySQL installations have distinct configuration tweaks to ensure high performance on high traffic websites. When using this generic docker based MySQL do not run heavy workloads like your customer facing website.
We do provide some MySQL images that are close to our full service configured MySQL instances:
A simple list of available tags can be found here:
Place to following files in
version: "3.2" services: mysql: image: registry.hipex.cloud/hipex-services/docker-image-mysql/8.0:v1.0.1 restart: "always" volumes: - data:/var/lib/mysql ports: - "13600:3600" environment: MYSQL_ROOT_PASSWORD: "rootchangeme" MYSQL_USER: "user" MYSQL_PASSWORD: "changeme" MYSQL_DATABASE: "database" volumes: data:
Then start your MySQL container with
hipex docker:compose:up -d. You can follow the logs to see what is happening with
hipex docker:compose:logs --follow. Once the container is up and running you can connect to port
13600 with the
username / password configured in the environment variables.
Since you can not just copy the MySQL data files a backup need to be created periodically with MySQL dump. This can be done with this cronjob to create a backup every night at 2:00.
Firt create the backup folder:
mkdir ~/domains/example.com/mysql/backups. And configure the cronjob:
0 2 * * * ~/domains/example.com/mysql && hipex docker:compose:exec mysql -T -- mysqldump --single-transaction --quick -u user -p'changeme' database | gzip > backups/backup.sql.gz