Table of contents
2.3 Neo4j environment configuration
1. What is Neo4j
As I understand it, it is a graph database, that is, a database that can use graphs to display data relationships. Suitable for data that needs to handle complex relationships. The description of the specific profession can be found in the Neo4j skill tree
2. Neo4j installation
2.1 Neo4j download
[Note: I choose the 4.x version here, because I use jdk11, if I download the latest 5.x version, there will be an error report that the jdk does not match it, as follows]
[You will need to fill in some information for the first download, just fill in as required]
2.2 Startup of neo4j
[First unzip the downloaded installation package, then I rename it to neo4j for easy search, and then move neo4j to /usr/local]
prodeMacBook-Pro:~ pro$ cd /usr/local/neo4j
prodeMacBook-Pro:neo4j pro$ cd bin
prodeMacBook-Pro:bin pro$ ./neo4j start
[After the completion, if it goes well, you will see such a prompt]
[The startup is successful here! 】
[If your jdk version does not correspond to the downloaded neo4j version, the prompt mentioned above will appear]
prodeMacBook-Pro:bin pro$ java -version //View jdk version
[If you have not downloaded jdk, you can download it again. Regarding the version correspondence, I only know that neo4j (4.x) corresponds to jdk (11.x)]
2.3 Neo4j environment configuration
prodeMacBook-Pro:~ pro$ vi ~/.bash_profile //Edit document
# Add the following content:
export NEO4J_HOME=/usr/local/neo4j
export PATH=$PATH:$NEO4J_HOME/bin
[Change the blue field to the path of your neo4j, then save and exit:]
esc
:wq
[Refresh modification:]
prodeMacBook-Pro:~ pro$ source ~/.bash_profile
[Complete configuration! Before starting neo4j this time, remember to close it first: use ./neo4j stop under /usr/local/neo4j/bin ]
3. Use of Neo4j
3.1 Open the web page
[There is an address in the prompt of successful operation, copy it to]
[I also downloaded neo4j desktop and was prompted to change the port when connecting to the DBMS]
【Go to: http://localhost:11004 】
3.2 Connect to neo4j
【Fill in the relevant information to complete the connection】
URL: I chose the bolt corresponding port number 11003
username: Feel free to fill in
password: I used the password set when I downloaded the installation package
【connection succeeded! 】
3.3 Getting Started
3.3.4 Create a node
# Create a person class node, press Enter to run
create(person:Person{name:"liluo",age:7});
【Created successfully】
3.3.5 Query
# query all nodes
match (n) return n
# Query the tags with the tag name DOG, and take out the first 2 after sorting by the name attribute
match (n:DOG) return n order by n.name limit 2
# Query the node with the specified label and attribute
match (n:DOG) where n.name='stich' return n
3.3.6 Building Relationships
# Establish a relationship between person and dog nodes (new line: shift+enter)
match (person:Person),(dog:DOG)
where person.name="liluo" and dog.name="stich"
create(person)-[r:R{isOwner:"yes"}]->(dog)
return r
4. Summary
It's the first time I use it, and I don't know how to match the jdk version. After tossing and tossing, it's not difficult to look back. After passing this hurdle, it can be said that everything went smoothly, but it is really difficult to get started.
In the middle, there are references to other related blogs, some of which are too early to correspond to the updated neo4j, some of which are different systems, and the skill tree of neo4j is more useful in the end (excellent, although the skill tree is about linux, the difference is not big.)
The above is a summary of the initial use of neo4j this time.