github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/test/utils/run_sql (about) 1 #!/bin/bash 2 set -e 3 4 host="127.0.0.1" 5 port=3306 6 user="root" 7 password="" 8 sql="" 9 ssl_key="" 10 ssl_cert="" 11 quiet=0 12 13 while [[ ${1} ]]; do 14 case "${1}" in 15 --host) 16 host=${2} 17 shift 18 ;; 19 --port) 20 port=${2} 21 shift 22 ;; 23 --user) 24 user=${2} 25 shift 26 ;; 27 --password) 28 password=${2} 29 shift 30 ;; 31 --ssl-key) 32 ssl_key=${2} 33 shift 34 ;; 35 --ssl-cert) 36 ssl_cert=${2} 37 shift 38 ;; 39 --quiet) 40 quiet=1 41 ;; 42 *) 43 sql="$sql ${1}" 44 ;; 45 esac 46 47 if ! shift; then 48 echo 'Missing parameter argument.' >&2 49 exit 1 50 fi 51 done 52 53 cmd="mysql -u${user} -h${host} -P${port}" 54 if [[ -n ${password} ]]; then 55 cmd="${cmd} -p${password}" 56 fi 57 if [[ -n ${ssl_key} ]]; then 58 cmd="${cmd} --ssl-key=${ssl_key}" 59 fi 60 if [[ -n ${ssl_cert} ]]; then 61 cmd="${cmd} --ssl-cert=${ssl_cert}" 62 fi 63 cmd="${cmd} --default-character-set utf8mb4 -e \"${sql}\"" 64 65 if [[ ${quiet} -ne 1 ]]; then 66 echo "will execute: $cmd" >&2 67 fi 68 set -f 69 eval $cmd 70 set +f