forked from msoos/cryptominisat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmsat_mysql_setup.sh
More file actions
executable file
·48 lines (42 loc) · 1.54 KB
/
Copy pathcmsat_mysql_setup.sh
File metadata and controls
executable file
·48 lines (42 loc) · 1.54 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
#!/bin/bash
DROP_USER="DROP USER 'cmsat_solver'@'localhost';"
DROP_USER2="DROP USER 'cmsat_presenter'@'localhost';"
SETUP_DB="
FLUSH PRIVILEGES;
drop database if exists cmsat;
create database cmsat;
use cmsat;
create user 'cmsat_solver'@'localhost' identified by '';
grant insert,update on cmsat.* to 'cmsat_solver'@'localhost';
create user 'cmsat_presenter'@'localhost' identified by '';
grant select on cmsat.* to 'cmsat_presenter'@'localhost';"
if [ $1 ]; then
echo "Using password '$1' for root access to mysql"
echo "$DROP_USER" | mysql -u root --password="$1" 2> /dev/null
echo "$DROP_USER2" | mysql -u root --password="$1" 2> /dev/null
echo "$SETUP_DB" | mysql -u root --password="$1"
if [ $? -ne 0 ]; then
echo "ERROR: Cannot create database! Maybe wrong password?";
exit -1;
fi
mysql -u root --password="$1" cmsat < cmsat_tablestructure.sql
if [ $? -ne 0 ]; then
echo "ERROR: Cannot add tables to database!";
exit -1;
fi
else
echo "Not using any password for root access to mysql"
echo "$DROP_USER" | mysql -u root 2> /dev/null
echo "$DROP_USER2" | mysql -u root 2> /dev/null
echo "$SETUP_DB" | mysql -u root
if [ $? -ne 0 ]; then
echo "ERROR: Cannot create database!";
exit -1;
fi
mysql -u root cmsat < cmsat_tablestructure.sql
if [ $? -ne 0 ]; then
echo "ERROR: Cannot add tables to database!";
exit -1;
fi
fi
echo "Created DB, set up users cmsat_solver and cmsat_presenter, and added tables"