diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/INSTALL | 3 | ||||
-rwxr-xr-x | sql/create_db.sh | 31 |
2 files changed, 15 insertions, 19 deletions
diff --git a/sql/INSTALL b/sql/INSTALL index e78334c..340d656 100644 --- a/sql/INSTALL +++ b/sql/INSTALL @@ -1 +1,2 @@ -Run the ./create_db.sh shell script to create the database. +Run the ./create_db.sh shell script to create the database. You will have to +enter the MySQL root user password when prompted. diff --git a/sql/create_db.sh b/sql/create_db.sh index 5b3fe17..5bf54af 100755 --- a/sql/create_db.sh +++ b/sql/create_db.sh @@ -1,4 +1,4 @@ -Â#!/bin/sh +#!/bin/sh drop="y" echo "Drop existing database and user? (y/n) [$drop]" @@ -8,7 +8,7 @@ if [ "$x" ] ; then drop=$x fi -dbname="PassMan" +dbname="passman" echo "Name of database to create [$dbname]:" read x @@ -16,7 +16,7 @@ if [ "$x" ] ; then dbname=$x fi -uname="PassMan" +uname="passman" echo "Name of database user to create [$uname]:" read x @@ -24,7 +24,7 @@ if [ "$x" ] ; then uname=$x fi -pword="PassMan" +pword="PassMan123!" echo "Password of database user [$pword]:" read x @@ -38,34 +38,29 @@ touch $script if [ "$drop" = "y" ] ; then cat >> $script << END_OF_DROP -drop database $dbname; -delete from mysql.user where username='$uname'; +drop database if exists $dbname; +drop user if exists '$uname'@'localhost'; END_OF_DROP fi cat >> $script << END_OF_SQL create database $dbname; -grant all on $dbname to '$uname'@'localhost' identified by '$pword'; use $dbname; - -create table pm_user -( - name varchar(256) not null, - password varchar(256) not null, - constraint pk_pm_user primary key(name) -); +grant all on *.* to '$uname'@'localhost' identified by '$pword'; create table pm_store ( - name varchar(256) not null, + id int not null auto_increment, description varchar(1024) not null, username varchar(256) not null, - password varchar(256) not null - constraint pk_pm_user primary key(name, description) + password varchar(256) not null, + primary key (id) ); END_OF_SQL -cat $script +cat -n $script +mysql -u root -p < $script + rm -f $script |