Skip to content

Commit 15a641c

Browse files
authored
Use Mysql official docker image (#8003)
1 parent fbd1e97 commit 15a641c

File tree

3 files changed

+14
-48
lines changed

3 files changed

+14
-48
lines changed

toolset/databases/mysql/create.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# http://stackoverflow.com/questions/37719818/the-server-time-zone-value-aest-is-unrecognized-or-represents-more-than-one-ti
33
SET GLOBAL time_zone = '+00:00';
44

5-
CREATE USER 'benchmarkdbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
6-
CREATE USER 'benchmarkdbuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
5+
CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
6+
CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
77

88
-- GitHub Actions/CI run the database server on the same system as the benchmarks.
99
-- Because we setup MySQL with the skip-name-resolve option, the IP address 127.0.0.1 might not be resolved to localhost
1010
-- anymore. This does not seem to matter, as long as Unix sockets are being used (e.g. when setting up the docker image),
1111
-- because the host is set to be localhost implicitly, but it matters for local TCP connections.
12-
CREATE USER 'benchmarkdbuser'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
12+
CREATE USER IF NOT EXISTS 'benchmarkdbuser'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY 'benchmarkdbpass';
1313

1414
# modified from SO answer http://stackoverflow.com/questions/5125096/for-loop-in-mysql
15-
CREATE DATABASE hello_world;
15+
CREATE DATABASE IF NOT EXISTS hello_world;
1616
USE hello_world;
1717

1818
CREATE TABLE world (

toolset/databases/mysql/my.cnf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[client]
66
port = 3306
77
socket = /var/run/mysqld/mysqld.sock
8+
default-character-set=utf8
89

910
#######################
1011
# mysqld #
@@ -20,6 +21,8 @@ default_authentication_plugin = mysql_native_password
2021
user = mysql
2122
pid-file = /var/run/mysqld/mysqld.pid
2223
socket = /var/run/mysqld/mysqld.sock
24+
datadir = /ssd
25+
secure-file-priv= NULL
2326
port = 3306
2427
skip-external-locking
2528
skip-name-resolve
Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,9 @@
1-
FROM ubuntu:22.04
1+
FROM mysql:8.0-debian
22

3-
ARG MYSQL_VERSION=8.0
3+
ENV MYSQL_ROOT_PASSWORD=root
4+
ENV MYSQL_USER=benchmarkdbuser
5+
ENV MYSQL_PASSWORD=benchmarkdbpass
6+
ENV MYSQL_DATABASE=hello_world
47

5-
COPY create.sql /tmp/
6-
COPY my.cnf ./
7-
8-
ARG DEBIAN_FRONTEND=noninteractive
9-
ADD "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x859be8d7c586f538430b19c2467b942d3a79bd29" \
10-
/etc/apt/keyrings/mysql.asc
11-
RUN chmod 644 /etc/apt/keyrings/mysql.asc && \
12-
apt-get -yqq update && \
13-
apt-get -yqq install \
14-
apt-utils \
15-
locales \
16-
lsb-release && \
17-
echo "deb [ signed-by=/etc/apt/keyrings/mysql.asc ] http://repo.mysql.com/apt/ubuntu $(lsb_release -cs) mysql-${MYSQL_VERSION}" > \
18-
/etc/apt/sources.list.d/mysql.list && \
19-
locale-gen en_US.UTF-8
20-
21-
ENV LANG=en_US.UTF-8
22-
ENV LANGUAGE=en_US:en
23-
ENV LC_ALL=en_US.UTF-8
24-
25-
# https://bugs.mysql.com/bug.php?id=90695
26-
RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-server mysql-server/lowercase-table-names select Enabled\""]
27-
RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/data-dir select 'Y'\""]
28-
RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/root-pass password secret\""]
29-
RUN ["/bin/bash", "-c", "debconf-set-selections <<< \"mysql-community-server mysql-community-server/re-root-pass password secret\""]
30-
RUN apt-get -yqq update && \
31-
apt-get -yqq install mysql-server && \
32-
mv /etc/mysql/my.cnf /etc/mysql/my.cnf.orig && \
33-
mv my.cnf /etc/mysql/my.cnf && \
34-
rm -rf /ssd/log/mysql /ssd/mysql && \
35-
cp -Rp /var/lib/mysql /ssd && \
36-
cp -Rp /var/log/mysql /ssd/log && \
37-
mkdir -p /var/run/mysqld && \
38-
chown -R mysql:mysql /ssd /var/lib/mysql /var/log/mysql /var/run/mysqld && \
39-
(mysqld &) && \
40-
until mysqladmin -uroot -psecret ping; do sleep 1; done && \
41-
mysqladmin -uroot -psecret flush-hosts && \
42-
mysql -uroot -psecret < /tmp/create.sql && \
43-
mysqladmin -uroot -psecret shutdown && \
44-
chown -R mysql:mysql /ssd /var/lib/mysql /var/log/mysql /var/run/mysqld
45-
46-
CMD ["mysqld"]
8+
COPY my.cnf /etc/mysql/
9+
COPY create.sql /docker-entrypoint-initdb.d/

0 commit comments

Comments
 (0)