summaryrefslogtreecommitdiff
path: root/sql/create_db.sh
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-06-22 07:43:22 +0000
committerIan C <ianc@noddybox.co.uk>2018-06-22 07:43:22 +0000
commit425d4b29e12648a9396050108e215b1be68a1bfe (patch)
treeca60bbcf471726025be64517b44c36ce86338d66 /sql/create_db.sh
parent87bbd53dbeb987e7cdd125a6ef15a48712a95368 (diff)
Finished db creation script.
Diffstat (limited to 'sql/create_db.sh')
-rwxr-xr-xsql/create_db.sh31
1 files changed, 13 insertions, 18 deletions
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