Skip to content

Instantly share code, notes, and snippets.

@rogeriopradoj
Last active May 29, 2019 21:47
Show Gist options
  • Save rogeriopradoj/f451063d6017cf990a7cc551dbd202a8 to your computer and use it in GitHub Desktop.
Save rogeriopradoj/f451063d6017cf990a7cc551dbd202a8 to your computer and use it in GitHub Desktop.
macOS: Create a mysql docker-based container and open Sequel Pro as GUI manager - https://git.io/sequel-pro-docker

macOS: Create a mysql docker-based container and open Sequel Pro as GUI manager

https://git.io/sequel-pro-docker by @RogerioPradoJ


Start

Go to terminal and run:

docker run \
  --name sequel-pro \
  --env MYSQL_ROOT_PASSWORD=my-secret-pw \
  --publish 3306:3306 \
  --detach \
  mysql

After that, you can choose to open/configure Sequel Pro via GUI or one-line CLI (pick the best for you):

Or via CLI:

sequel-pro-docker.sh

See how to download/update this script below.

Or via GUI:

  1. Open Sequel Pro and go to New connection
  2. Choose Standard
  3. Host: 127.0.0.1
  4. Username: root
  5. Password: my-secret-pw

In the end: Close and remove mysql container

In Terminal:

docker rm -f sequel-pro

Misc

How to download/update sequel-pro-docker.sh script

curl -L https://git.io/sequel-pro-docker-update-sh | bash

What's inside these scripts you're suggesting to pipe into my bash ?!?!?

Don't worry, take a look at all the shorten git.io urls below, they are the open sourced files on this own gist:

keywords

  • mac
  • macOS
  • MySQL
  • Docker
  • Sequel Pro
#!/usr/bin/env bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/}
${0##*/} -h
Update sequel-pro-docker.sh
Options:
-h display this help and exit
EOF
}
while getopts :u:p:P:H:h opt; do
case $opt in
h)
show_help
exit 0
;;
\?)
show_help >&2
exit 1
;;
:)
show_help >&2
exit 1
;;
esac
done
indent_output() {
while read data; do
echo -e " \033[1;32m|\033[0m $data"
done
}
colorize_output() {
while read data; do
echo -e "\033[1;32m$data\033[0m"
done
}
sh_local() {
mkdir -p /usr/local/bin
localsh='/usr/local/bin/sequel-pro-docker.sh'
HASH_CURRENT=`cat $localsh 2>/dev/null | openssl dgst -sha256`
}
sh_latest() {
url='https://git.io/sequel-pro-docker-sh'
tempprefix=`basename $0`
TMPFILE=`mktemp -t ${tempprefix}` || exit 1
curl -o $TMPFILE -L --silent "$url"
HASH_LATEST=`cat $TMPFILE | openssl dgst -sha256`
}
local_is_old() {
sh_local
sh_latest
if [ "$HASH_LATEST" == "$HASH_CURRENT" ];
then
# 1=false
return 1
fi
# 0=true
return 0
}
update_local() {
echo
if local_is_old ; then
mv $TMPFILE $currentsh
chmod a+x $TMPFILE
fi
}
echo
echo "Starting..." | colorize_output
update_local
echo "Done." | indent_output
echo | indent_output
echo "Updated with latest version/hash: $HASH_LATEST" | indent_output
exit 0
#!/usr/bin/env bash
# Original borrowed from https://gist.github.com/helderco/e9d8d072a362ad818f6a
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.
Options:
-h display this help and exit
-u USER database user (defaults to root)
-p PASS database password (defaults to my-secret-pw)
-P PORT database port (defaults to published port for 3306
in container named as sequel-pro)
-H HOST database host (defaults to 127.0.0.1)
DATABASE database name (defaults to none)
EOF
}
while getopts :u:p:P:H:h opt; do
case $opt in
u) DB_USER="$OPTARG"
;;
p) DB_PASS="$OPTARG"
;;
P) DB_PORT="$OPTARG"
;;
H) DB_HOST="$OPTARG"
;;
h)
show_help
exit 0
;;
\?)
show_help >&2
exit 1
;;
:)
show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
: ${DB_USER:=root}
: ${DB_PASS:=my-secret-pw}
: ${DB_PORT:=$(docker ps --filter name=sequel-pro | tail -1 | cut -d: -f2 | cut -d- -f1)}
: ${DB_HOST:=127.0.0.1}
: ${DB_NAME:=$1}
TMP_SPF='/tmp/docker.spf'
cat > $TMP_SPF <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ContentFilters</key>
<dict/>
<key>auto_connect</key>
<true/>
<key>data</key>
<dict>
<key>connection</key>
<dict>
<key>database</key>
<string>${DB_NAME}</string>
<key>host</key>
<string>${DB_HOST}</string>
<key>name</key>
<string>docker.sequel-pro</string>
<key>password</key>
<string>${DB_PASS}</string>
<key>port</key>
<integer>${DB_PORT}</integer>
<key>rdbms_type</key>
<string>mysql</string>
<key>sslCACertFileLocation</key>
<string></string>
<key>sslCACertFileLocationEnabled</key>
<integer>0</integer>
<key>sslCertificateFileLocation</key>
<string></string>
<key>sslCertificateFileLocationEnabled</key>
<integer>0</integer>
<key>sslKeyFileLocation</key>
<string></string>
<key>sslKeyFileLocationEnabled</key>
<integer>0</integer>
<key>type</key>
<string>SPTCPIPConnection</string>
<key>useSSL</key>
<integer>0</integer>
<key>user</key>
<string>${DB_USER}</string>
</dict>
</dict>
<key>encrypted</key>
<false/>
<key>format</key>
<string>connection</string>
<key>queryFavorites</key>
<array/>
<key>queryHistory</key>
<array/>
<key>rdbms_type</key>
<string>mysql</string>
<key>rdbms_version</key>
<string>5.7.16</string>
<key>version</key>
<integer>1</integer>
</dict>
</plist>
EOF
exec open $TMP_SPF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment