Neo4j is an open-source, graph database management system Written in Java. Unlike the traditional relational databases such as SQL which have tables with rows and columns, a graph database is characterized by nodes, edges, and properties.
Graph databases usually offer better performance than their SQL and NoSQL counterparts.
In a graph database, data is modeled as nodes and relationships between those data nodes. Neo4j can query complex relationships with low overhead since all the nodes have references to other nodes that are related. Neo4j is available in a community edition that is free and an enterprise edition for commercial purposes.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related database management system queries.
In this context, we shall look into the installation and configuration of Neo4j on Ubuntu 20.04
1. Perform System Update
We recommend updating that package index of your system before proceeding. Therefore, launch your terminal and run the following command:
$ sudo apt update
2. Install System Packages
Next, we will install a few additional packages. These packages may already be present in your Ubuntu 20.04 system, but you can still run the below command:
$ sudo apt install software-properties-common apt-transport-https ca-certificates
3. Download and Add GPG Key
The Neo4j database engine isn't included in the official Ubuntu package repository. We need to add the GPG key from Neo that will allow us to install Neo4j on Ubuntu 20.04
So, proceed and download and add the Neo4j GPG key:
$ wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
Thereafter, add the Neo4j 4.3 repository to the sources list file:
$ echo 'deb https://debian.neo4j.com stable 4.3' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
Next, refresh the package lists:
$ sudo apt update
4. Install Neo4j
Here, we will install Neo4j. This will also download a few other dependencies needed by neo4j. Additionally, a compatible Java version will be installed on your system. Run the command:
$ sudo apt install neo4j
Once the installation is done, enable and start the Neo4j service by running the following command:
$ sudo systemctl enable neo4j.service
$ sudo systemctl start neo4j.service
Verify neo4j is installed and running successfully:
$ sudo systemctl status neo4j.service
Now that Neo4j is up and running, we can connect to the database and set up administrator credentials. To achieve this, we will leverage the cypher-shell which is a command-line utility for running queries against the Neo4j database instance.
So, fire up the interactive shell with the command:
Once you start the shell, log in with the default credentials:
For obvious security reasons, you will be required to set a new strong password. So go along and provide a robust password.
Here, we will access the Neo4j web dashboard. So, launch your favorite web browser and visit the URL shown to access Neo4J login page:
By default, Neo4j is configured to accept only connections from localhost IP addresses. The reason behind this is to provide some added security for the database engine.
To access Neo4j from an external system, edit the /etc/neo4j/neo4j.conf file, locate and uncomment the following line:
You can also specify your server’s IP address in the configuration file.
Now, to access Neo4j dashboard, use your the administrator login details. You will see the Neo4j web interface.
This article covers the process of installing Neo4j on Ubuntu 20.04 Linux system. In fact, Neo4j is a graph database that records relationships between data nodes, whereas traditional relational databases use rows and columns to store and structure data.
How to use Neo4j ?
To start using Neo4j, let's add some example nodes and then define relationships between them. Connect to Neo4j using cypher-shell: