Complete Beginner Guide to Install Post Apache AGE Setup + Apache Viewer on Windows 10 Pro with WSL2 Part-2
Tags: postgres, database, apacheage, windows
Published: 2023-06-16 21:37:31

This guide aims to assist you in Post Apache-AGE setup and seamlessly integrating it with Apache Viewer on your Windows system. It is designed to provide a step-by-step walkthrough, ensuring a straightforward installation process. While there is an informative [YouTube](https://www.youtube.com/watch?v=ddk8VX8Hm-I&ab_channel=MatheusFarias) video available, I personally encountered some minor difficulties while following it. Hence, this guide aims to simplify the process further.

**Note: You must have installed _postgreSQL_ and integrated it with _Apache AGE_ before following this blog.**

> _If you haven't installed **PostgreSQL** or **Apache AGE** yet, checkout **[Part-1](https://dev.to/vkt1271/complete-beginner-guide-to-install-postgresql-apache-age-on-windows-10-pro-with-wsl2-part-1-fco)**._

------------------------------------------------------------

## Post Installation Apache-AGE Setup

Before proceeding with the installation of Apache Viewer, it is necessary to create a **demo database**. This will allow us to better understand how we can manipulate databases to solve real-world problems. Therefore, I recommend to follow below steps:

**Step:1**

Now, navigate back to the **home directory**, type `cd` in the terminal and follow certain commands given, and shown in photo below:

- `cd postgresql-11.18/`
- `cd bin`
- `initdb demoDataBase`
- `cd ..`
- `initdb demoDataBase`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zfh6vjs9myknwg8ydy14.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f92g1vw4e0inkvhxjuvc.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2mv4jjke7r2i9927x80.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bg84e5rsu5lxf904p5qv.png)

After above sub-steps, we need to start server. Make sure, you are **inside postgresql-11.18 directory** and follow below sub-steps:

- `bin/pg_ctl -D demoDataBase -l logfile start`

After execution of above sub command, your Server will start
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i03fgfpad6ipz9nr1fdj.png)

- `bin/createdb demoDataBase`
- `bin/psql demoDataBase`

After this, you will be entered to manipulate **demoDataBase** created above.

**Step:2**

Try to follow below commands like shown in pictures below

- `CREATE EXTENSION age;`
- `LOAD 'age';`
- `SET search_path = ag_catalog, "$user", public;`
- `SELECT * FROM ag_catalog.create_graph('taxonomy_biology');`
- `SELECT * FROM cypher('taxonomy_biology', $$ CREATE (:Kingdom{name: 'Animalia'}) $$) as (a agtype);`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adgcszi627gllyf5titz.png)

- `SELECT * FROM cypher('taxonomy_biology', $$ CREATE (:Phylum{name: 'Cnidaria'}) $$) as (a agtype);`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtrkmoxy89wc2r1wfgqo.png)

- `SELECT * FROM cypher('taxonomy_biology', $$ MATCH (a: Kingdom), (b: Phylum) WHERE a.name = 'Animalia' AND b.name = 'Cnidaria' CREATE (b)-[e: BELONGS_TO]->(a) RETURN e $$) as (edge agtype);`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xv4as61yx3r6kooketdq.png)

- `SELECT * FROM cypher('taxonomy_biology', $$ MATCH (v) RETURN v $$) as (vertex agtype);`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5k031nepnibhazms7jmm.png)

- `SELECT * FROM cypher('taxonomy_biology', $$ MATCH (a)-[e]->(b) RETURN a, e, b $$) as (vertex_start agtype, edge agtype, vertex_end agtype);`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awm4eyonizrqmxoyiv7j.png)

- Type `\q` to get exit from demoDataBase=#

Till here, demoDataBase has been created and demo data has also been inserted using above commands. Type `cd` to get back to home directory.

Hurrah! **Post Apache-AGE Setup** has been successfully installed in your system.

------------------------------------------------------------

## Install Apache-Viewer

Now, clone the Apache Viewer repository into the home directory(type `cd`). Therefore, I recommend to follow below steps:

**Step:1**
`git clone https://github.com/apache/age-viewer.git`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3abpl1hf36khs3n2ideb.png)

**Step:2**
Now, `cd` into the cloned folder and run the command `npm run setup`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwc92iw3b7njxs79xnk0.png)

**Step:3**
Run the command `npm run start`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynsiqn0l9rr6r5ktqoga.png)

After Step-3, you will be redirected to development server as shown below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9l0rvf4ol8728zzd41h.png)

**Step:4**
In this step, you have to enter your details to connect with demoDataBase.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afq51bw5ed89gryj6g0m.png)

After you press connect, if credentials are correct then, database will be connected.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7td50qzgbt397zsdg9b.png)

Hurrah! **Apache-Viewer** has been successfully installed in your system.

------------------------------------------------------------

## Some Apache-Viewer Interactions

- You can see the queries like shown below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ithome8je939vfqgwu9.png)

- You can run and see Graphical representation of the queries like shown below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjt69lrn7la6z5ibdk8q.png)

----------------------------------------------------------------

Hurrah! **Post Apache AGE Setup** and **Apache-Viewer** has been successfully installed in your system. Start studying more about [postgresql](https://www.interdb.jp/pg/)

I hope, this blog has helped you for successful installation.

Checkout [Part-1](https://dev.to/vkt1271/complete-beginner-guide-to-install-postgresql-apache-age-on-windows-10-pro-with-wsl2-part-1-fco) too.