Neo4j Getting Started
Neo4j is the world’s leading Graph Database. It is a high performance graph store with all the features expected of a mature and robust database, like a friendly query language and ACID transactions. The programmer works with a flexible network structure of nodes and relationships rather than static tables — yet enjoys all the benefits of enterprise-quality database. For many applications, Neo4j offers orders of magnitude performance benefits compared to relational DBs.
If you have installed Websoft9 Neo4j, the following steps is for your quick start
Preparation
- Get the Internet IP of your Server on Cloud
- Check your Inbound of Security Group Rule of Cloud Console to ensure the TCP:80,7687 is allowed
- Complete Five steps for Domain if you want to use Domain for Neo4j
- Get default username and password of Neo4j
Neo4j Initialization
Steps for you
-
Use SSH to connect Neo4j Server, run the command
cypher-shell
, you should input your username and password for this command.(Don't known password?)$cypher-shell
username: neo4j
password: *****
Connected to Neo4j 4.1.0 at neo4j://localhost:7687 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j@neo4j> -
Run the command
CALL dbms.showCurrentUser();
to show all usersneo4j@neo4j> CALL dbms.showCurrentUser();
+--------------------------+
| username | roles | flags |
+--------------------------+
| "neo4j" | admin | [] |
+--------------------------+
1 row available after 22 ms, consumed after another 1 ms -
Try the GUI tool Neo4j Browser(Neo4j Browser)
More useful Neo4j guide, please refer to Neo4j Documentation
Having trouble?
Below is for you to solve problem, and you can contact Websoft9 Support or refer to Troubleshoot + FAQ to get more.
I can visit Neo4j Browser but database connection error?
Your TCP:7687 of Security Group Rules is not allowed so that Neo4j Browser can't connect Neo4j from this port
WhyNeo4j Browser roles is null?
Neo4j Community Edition not support roles
Neo4j QuickStart
We will provide a quick guide for you to use Neo4j Browser, you can get a complete data analysis.
Use sample data for analysis
You can use the sample Movie Graph on the Neo4j Browser console for the following steps:
- Create data
- Query node
- Solve relationship
-
Login to Neo4j Browser
-
Open:【Sample Scripts】>【Example Graphs】>【Movie Graph】, click 【Create】icon at 2/8
-
You can see the relationship graph
-
Complete the more steps
Create data for analysis
-
Login Neo4j Browser, run the following command to create Node data
create (n:Person { name: 'Tom Hanks', born: 1956 }) return n;
create (n:Person { name: 'Robert Zemeckis', born: 1951 }) return n;
create (n:Movie { title: 'Forrest Gump', released: 1951 }) return n; -
Run the query command to show graph
match(n) return n;
-
Create relationship by the following command
MATCH (a:Person),(b:Movie)
WHERE a.name = 'Robert Zemeckis' AND b.title = 'Forrest Gump'
CREATE (a)-[r:DIRECTED]->(b)
RETURN r; -
Run the query
match(n) return n;
Import data for analysis
Refer to :KGData Industry Graph Data
Neo4j Setup
Enable remote connection
-
Check Inbound of Security Group Rule of Cloud Console to ensure the 7687 allowed
-
Check Neo4j configuration file have accept all IP connection(0.0.0.0 mean allowed)
# With default configuration Neo4j only accepts local connections.
# To accept non-local connections, uncomment this line:
dbms.default_listen_address=0.0.0.0
Manage Users
First you can read the official docs: User and role management to get basic knowledge.
The following is some useful command for user management:
# Show all users
SHOW USERS;
# Create new user
# Show all users
SHOW USERS;
CALL dbms.security.listUsers();
# Create new user, the third parameter is requridchangepassword
CALL dbms.security.createUser('username','password',false);
# Delete user
CALL dbms.security.deleteUser('username');
GUI
Neo4j have some useful GUI tools, include web-based and desktop, support Windows, Linux, macOS.
Before use GUI tool, you should enable remote connection
Neo4j Browser
Neo4j Browser is a web-base tool for Neo4j, included in the Neo4j Server by default
- Using local Chrome visit the URL http://domain or http://Server's Internet IP, access to Neo4j Browser
- Select 【bolt://】URL mode, and input the default username and password, then the system may force a password change.
Pick neo4j:// for a routed connection, bolt:// for a direct connection and fast than neo4j://
- After modifying the new password, the system logs in to the console and initializes the installation.
- You can add user by Database Information > server user add (Enterprise Edition)
Neo4j Desktop
Neo4j Desktop is a local tool for developer.
Neo4j Bloom
Neo4j Bloom is the graph visualization and exploration tool
Reset Password
There are two main measures to reset password for Neo4j
Changing password
You can change password using jut one command below sample:
# Change old password "neo4j" to new password "neo4j123"
echo "
ALTER CURRENT USER SET PASSWORD FROM 'neo4j' TO 'neo4j123';
" | cypher-shell -u neo4j -p neo4j -d system
Forgot Password
Try to retrieve your password through the following steps when forgot it:
-
Stop Neo4j server
sudo systemctl stop neo4j
-
Modify Neo4j configuration file, set
#dbms.security.auth_enabled=false
to the following valuedbms.security.auth_enabled=false
-
Restart Neo4j and set a new password
sudo systemctl start neo4j
cypher-shell -d system
neo@system> ALTER USER neo4j SET PASSWORD 'mynewpass';
neo@system> :exit -
Recovery Neo4j configuration file
-
Restart the Neo4j service
sudo systemctl restart neo4j
More details please refer to: Password and user recovery
Reference sheet
The below items and General parameter sheet is maybe useful for you manage Neo4j
下面仅列出 Neo4j 本身的 参数:
Path
运行 neo4j console
命令查看安装相关的路径:
Neo4j 程序路径:/var/lib/neo4j
Neo4j 配置文件路径:/etc/neo4j/neo4j.conf
Neo4j 日志路径:/var/log/neo4j
Neo4j 插件路径:/var/lib/neo4j/plugins
Neo4j 数据路径:/var/lib/neo4j/data
Neo4j 证书路径:/var/lib/neo4j/certificates
Neo4j 启动路径:/var/run/neo4j
更多安装路径请查看 neo4j.conf 文件,配置文件设置参考此处
Port
端口号 | 用途 | 必要性 |
---|---|---|
7687 | Neo4j Browser 远程连接 Neo4j database | 可选 |
更多的端口:Port on Configuration file
Version
neo4j-admin -V
neo4j version
Service
sudo systemctl start | stop | restart | status neo4j
CLI
Neo4j 通过了一系列的命令行工具,用于管理服务、导入数据、分析数据,详情参考:Neo4j Tools
Cypher Shell
Cypher Shell is a command-line tool that comes with the Neo4j installation. Cypher Shell is used to run queries and perform administrative tasks. It communicates via the encrypted binary protocol Bolt.
root@neo4j-test:~# cypher-shell
username: neo4j
password: *****
Connected to Neo4j 3.5.14 at bolt://localhost:7687 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j>
neo4j-admin
Neo4j Admin is the primary tool for managing your Neo4j instance. It is a command-line tool that is installed as part of the product and can be executed with a number of commands. Some of the commands are described in more detail in separate sections.
$ neo4j-admin help
Usage: neo4j-admin [-hV] [COMMAND]
Neo4j database administration tool.
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
help Displays help information about the specified command
memrec Print Neo4j heap and pagecache memory settings recommendations.
dump Dump a database into a single-file archive.
store-info Print information about a Neo4j database store.
report Produces a zip/tar of the most common information needed for remote assessments.
load Load a database from an archive created with the dump command.
check-consistency Check the consistency of a database.
import Import a collection of CSV files.
set-default-admin Sets the default admin user.
This user will be granted the admin role on startup if the system has no roles.
set-initial-password Sets the initial password of the initial admin user ('neo4j'). And removes the requirement to
change password on first login.
neo4j
$neo4j -h
Usage: neo4j { console | start | stop | restart | status | version }