-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdebug-db-reset.sh
More file actions
executable file
·38 lines (22 loc) · 899 Bytes
/
debug-db-reset.sh
File metadata and controls
executable file
·38 lines (22 loc) · 899 Bytes
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
#!/bin/bash
json="../../settings.json"
DB="$(cat $json | grep -A 5 dbSettings | grep user | tr '"' ' ' | tr ',' ' ' | tr -d '[[:space:]]' )"
db_usr="${DB:5}"
echo "user: $db_usr"
DB="$(cat $json | grep -A 5 dbSettings | grep host | tr '"' ' ' | tr ',' ' ' | tr -d '[[:space:]]' )"
db_host="${DB:5}"
echo "host: $db_host"
DB="$(cat $json | grep -A 5 dbSettings | grep password | tr '"' ' ' | tr ',' ' ' | tr -d '[[:space:]]' )"
db_pwd="${DB:9}"
echo "password: $db_pwd"
DB="$(cat $json | grep -A 5 dbSettings | grep database | tr '"' ' ' | tr ',' ' ' | tr -d '[[:space:]]' )"
db_name="${DB:9}"
echo "database: $db_name"
MDA="-u root"
SQL1="DROP DATABASE $db_name;"
echo "$SQL1"
SQL2="CREATE DATABASE IF NOT EXISTS $db_name;"
echo "$SQL2"
SQL3="GRANT ALL ON $db_name.* TO '$db_usr'@'localhost' IDENTIFIED BY '$db_pwd'; flush privileges;"
echo "$SQL3"
mysql $MDA -e "$SQL1 $SQL2 $SQL3"