-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmysql
More file actions
executable file
·81 lines (69 loc) · 1.8 KB
/
mysql
File metadata and controls
executable file
·81 lines (69 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
usage="$(basename "$0") -h HOST [-u USER] -- Wrapper to interact with docker containers
where:
-h docker-container 'host' name
-u MySQL user; required for 'proxy-sql' host, ignored in other hosts
--help shows this help text"
valid_hosts="
Host was either not supplied, or invalid.
Valid hosts are:
- proxysql1,proxysql2,proxysql3: admin interface for proxysql1,2,3
- proxy-sql: SQL interface of proxysql1
- primary: Master container for the rewrite and failover demonstrations
- replica: Slave container for the rewrite and failover demonstrations
- mysqla: MySQL 5.6 container for the mirror demonstration
- mysqlb: MySQL 5.7 container for the mirror demonstration"
valid_users="
User specified for proxy-sql host must be one of the following:
- pl_rewrite: Used to connect to the rewrite and failover cluster
- pl_mirror: Used to connect to the mirror environment"
[ $# -eq 0 ] && { echo "$usage"; exit 1; }
accounts="pl_rewrite
pl_mirror"
while [[ $# -ge 1 ]]
do
key="$1"
case $key in
-h|--host)
HOST="$2"
shift # past argument
;;
-u|--user)
USER="$2"
shift # past argument
;;
--help|*)
echo "$usage"
exit 0
;;
esac
shift # past argument or value
done
case $HOST in
proxysql1|proxysql2|proxysql3)
docker exec -it $HOST mysql -h 127.0.0.1 -P 6032 -u admin -padmin
;;
proxy-sql)
match=0
for u in $accounts; do
if [[ "$USER" == "$u" ]]; then
match=1
break
fi
done
if [[ $match -eq 0 ]]; then
echo "$usage
$valid_users"
exit 1
fi
docker exec -it proxysql1 mysql -h 127.0.0.1 -P 6033 -u $USER -pperconalive
;;
mysqla|mysqlb|primary|replica1)
docker exec -it $HOST mysql -u root -psecret
;;
*)
echo "$usage
$valid_hosts
"
;;
esac