diff --git a/Vagrantfile b/Vagrantfile index 666d67f..a4b7175 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -28,13 +28,12 @@ Vagrant.configure("2") do |config| #zu installierende Pakete apt-get install -y apache2 python3-django mariadb-server avahi-daemon \ - libnss-mdns libapache2-mod-wsgi-py3 python3-mysqldb + libnss-mdns libapache2-mod-wsgi-py3 python3-mysqldb - #So würde der Code aussehen um SQL Scripts in die DB zu importieren. - #mysql < /vagrant/sql/remove_db.sql - #mysql < /vagrant/sql/create_db.sql - #mysql < /vagrant/sql/add_data.sql + #initialize the db + mysql < /vagrant/sql/04_remove_database.sql + mysql < /vagrant/sql/01_create_database.sql #löschen und verlinken der HTML root damit man diese nicht manuel kopieren muss. if ! [ -L /var/www/html ]; then diff --git a/sql/01_create_database.sql b/sql/01_create_database.sql new file mode 100644 index 0000000..969aab8 --- /dev/null +++ b/sql/01_create_database.sql @@ -0,0 +1,14 @@ +-- Creates the webshop DB +-- +-- Author: Andreas Zweili +-- 2017-11-04 +-- MariaDB 10.1.26 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + +create database if not exists webshopdb; +grant all on webshopdb.* to + 'webshop'@'localhost' + identified by '2YKtY53F3HDDzPyExAaSh3jdVNh6VN'; +flush privileges; diff --git a/sql/04_remove_database.sql b/sql/04_remove_database.sql new file mode 100644 index 0000000..43f3630 --- /dev/null +++ b/sql/04_remove_database.sql @@ -0,0 +1,8 @@ +-- Removes the webshop DB +-- +-- Author: Andreas Zweili +-- 2017-11-04 +-- MariaDB 10.1.26 + +drop database if exists webshopdb; +drop user if exists webshop@localhost;