Skip to content

Commit

Permalink
Update socket location for mysql clients
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed Feb 25, 2022
1 parent 0c0f739 commit 9e0c503
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions 5.7/Dockerfile.oracle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions 5.7/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions 8.0/Dockerfile.oracle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions 8.0/docker-entrypoint.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions template/Dockerfile.oracle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ RUN set -eux; \
grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \
sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \
grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \
{ echo '[client]'; echo 'socket=/var/run/mysqld/mysqld.sock'; } >> /etc/my.cnf; \
\
# make sure users dumping files in "/etc/mysql/conf.d" still works
! grep -F '!includedir' /etc/my.cnf; \
Expand Down
15 changes: 15 additions & 0 deletions template/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ mysql_get_config() {
# match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)"
}

# Ensure that the package default socket can also be used
# since rpm packages are compiled with a different socket location
# and "mysqlsh --mysql" doesn't read the [client] config
# related to https://github.com/docker-library/mysql/issues/829
mysql_socket_fix() {
local defaultSocket
defaultSocket="$(mysql_get_config 'socket' mysqld --no-defaults)"
if [ "$defaultSocket" != "$SOCKET" ]; then
ln -sfTv "$SOCKET" "$defaultSocket" || :
fi
}

# Do a temporary startup of the MySQL server, for init purposes
docker_temp_server_start() {
if [ "${MYSQL_MAJOR}" = '5.7' ]; then
Expand Down Expand Up @@ -366,6 +378,7 @@ _main() {
docker_temp_server_start "$@"
mysql_note "Temporary server started."

mysql_socket_fix
docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*

Expand All @@ -378,6 +391,8 @@ _main() {
echo
mysql_note "MySQL init process done. Ready for start up."
echo
else
mysql_socket_fix
fi
fi
exec "$@"
Expand Down

0 comments on commit 9e0c503

Please sign in to comment.