InstallSampleData
Contents
Installing DHIS Example data requires a couple steps:
- Downloading the sample data
- Creating the dhis user in postgres
- Creating the database
- Importing the database from the sample data
1st Downloading the sample data
Download the zip file from here: http://www.dhis2.org/download/resources/dhis2-demo.zip
Extract it.
2nd Preparing the database
In your terminal / command line type the following to start the postgres command line:
psql -U postgres
Note: If you need additional options like port number see (psql --help) for more information
It will likely ask you for your password, so you should give it and you'll get into the postgres terminal.
Now we will add the dhis user to postgres using the following command. create user dhis createdb;
This will create the db user that is needed for the script.
Use \du
to check if it was actually created, you should see something similar to the following.
postgres=# \du
List of roles Role name | Attributes | Member of
dhis | Create DB | {} postgres | Superuser, Create role, Create DB, Replication | {}
Before we can import lets create the database (if you already have the database, you might want to drop it and re-create it, use DROP DATABASE dhis2)
create database dhis2;
We can now close the command line with
\q
3rd Importing the sample data
To import the database use the following command in the folder where you unzipped the file
psql -d dhis2 -U postgres -f default.sql
this stands for
psql -d <databasename> -U <username> -f <filename to run>
Happy hacking! :)