-
Notifications
You must be signed in to change notification settings - Fork 15
/
prepareDB.sh
executable file
·42 lines (35 loc) · 1.22 KB
/
prepareDB.sh
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
#!/bin/bash
#
# This script creates a new database and user for that database to use.
# Please don't forget to update malwarez/settings.py file with output of this script.
#
root_username='root'
malwarez_hostname="localhost"
malwarez_database="tmp_malwarez"
malwarez_username="tmp_malwarez"
malwarez_password="<malwarez_password>"
# prepare sql to execute
SQL="create database ${malwarez_database};\
create user '${malwarez_username}'@'${malwarez_hostname}' IDENTIFIED BY '${malwarez_password}';\
GRANT ALL PRIVILEGES ON ${malwarez_database}.* TO '${malwarez_username}'@'${malwarez_hostname}';\
FLUSH PRIVILEGES;"
# echo ${SQL}
# Execute query with root user. password will be asked before exevution
echo "Please enter password for mysql root user"
mysql -u${root_username} -p -e "${SQL}"
# Print the settings.py content
echo "Please update your malwarez/settings.py file with following code;"
echo "\
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '${malwarez_database}',
'USER': '${malwarez_username}',
'PASSWORD': '${malwarez_password}',
'HOST': '${malwarez_hostname}',
'PORT': '3306',
}
}
After update please run following command:
./manage.py syncdb
";