Testeach Inside Out and Back Again

Introduction

Memgraph is a native, in-memory graph database congenital for real-time business-critical applications. Memgraph supports strongly-consistent ACID transactions; and supports the Aught query language for structuring, manipulating, and exploring data.

Memgraph Lab is a lightweight and intuitive Goose egg and Bolt compatible integrated development environment (IDE). It's designed to assistance you import data, develop, debug, and contour database queries and visualize query results.

In this tutorial, you will install both Memgraph and Memgraph Lab on your Mac. You will then test each installation past running basic Cypher queries to make sure that everything is working correctly.

Prerequisites

For a seamless installation of Memgraph and Memgraph Lab on your Mac, ensure that you have:

  • A computer running macOS version 10.13 (High Sierra) or college.
  • Administrative rights to your macOS and an internet connection.
  • A Docker Hub business relationship, so that yous can download the Docker Desktop for Mac version 1.12 or college and install it on your computer.
  • Bones knowledge of working with the command line.

Step 1 — Downloading and Installing Memgraph

You tin can install Memgraph on macOS using the Docker image provided on Memgraph'south website. Download and save it to a location yous tin quickly locate later on.

Before nosotros go along, information technology's essential that you have Docker installed on your system then y'all are able to install and run Memgraph.

In one case you take Docker installed and the Memgraph Docker image downloaded, run the control below in your command line to begin the installation. Simply replace the <version> placeholder with the version number included in the filename of the Docker epitome you've just downloaded:

          docker load -i /path/to/memgraph-<version>-docker.tar.gz                  

At present, commencement the Memgraph server by issuing this control:

          docker run -p 7687:7687 -v mg_lib:/var/lib/memgraph -5 mg_log:/var/log/memgraph -5 mg_etc:/etc/memgraph memgraph                  

If successful, you should be greeted with the following bulletin:

          Starting 2 BoltS workers BoltS server is fully armed and operational BoltS listening on 0.0.0.0:7687                  

The server is now ready to process your queries.

If yous want to stop the server, press Ctrl + C or Cmd + .. If y'all do, make sure you run it dorsum again using the previous control. The server needs to be running to execute the next pace.

You now have Memgraph installed and running. The next step is to play around by executing some queries against information technology using the CLI (control-line interface) tool.

Pace ii — Querying Memgraph Through the CLI

Memgraph comes with a CLI tool named mg_client. Information technology allows you to execute Goose egg queries against the Memgraph server using the control line.

Memgraph supports the Cypher query through the openCypher project. Zippo is a SQL-like declarative query linguistic communication purposely designed to efficiently query and update holding graphs.

We'll at present test Memgraph by executing 2 bones queries that demonstrate the creation and retrieval of data from the database.

But earlier nosotros do that, we beginning need to recollect the IP address of our Docker container that runs the Memgraph server. The mg_client tool needs the IP address of the server to connect and run queries confronting it.

To do this, first, open a new window or tab in your control line. The window or tab you used to run the Memgraph server can't execute some other command. Merely run this command on a new window or tab:

          docker ps                  

Y'all should and so see an output similar to the following:

          CONTAINER ID        IMAGE           COMMAND                  CREATED         ... d1d9d4ce649f        memgraph        "/usr/lib/memgraph/thou…"   2 seconds ago   ...                  

The value we're interested in is the one in the CONTAINER ID cavalcade. In the example output to a higher place, it's d1d9d4ce649f.

Now, utilise the container ID to call back the IP accost of the container. Run the command beneath, at the aforementioned time, replacing CONTAINER_ID with your container ID:

          docker audit -f '' CONTAINER_ID                  

The command above will render a long JSON string that contains various properties that describe the container. Here'south a truncated version of it:

          [   {     "Id": "d1d9d4ce649fc5d78dee28eb946ac6f5b352f6ef1ee05eb6518bdec4061a55ef",     .......     "NetworkSettings": {         "Gateway": "172.17.0.1",         "IPAddress": "172.17.0.ii",         ......     }   } ]                  

Within the JSON string, expect for the value of the key named IPAddress equally this is the IP accost we are looking for. Yours volition vary, but, in our case, it's 172.17.0.2.

Next, run the mg_client with this command, and at the aforementioned time, correctly replacing HOST with your IP address:

          docker run -it --entrypoint=mg_client memgraph --host HOST                  

If the mg_client tin can connect to the server, you'll receive a prompt similar to this:

          mg_client 1.0.0 Type :aid for beat out usage Quit the beat past typing Ctrl-D(eof) or :quit Continued to 'memgraph://172.17.0.2:7687' memgraph>                  

Yous are now ready to execute Cypher queries on the server. Each query needs to terminate with the ; (semicolon) character.

Let'due south begin by executing this kickoff query:

          CREATE (u:User {proper name: "Alice"})-[:Likes]->(grand:Software {name: "Memgraph"});                  

The above volition create ii nodes in the database, ane labeled "User" with the proper name "Alice" and the other labeled "Software" with the name "Memgraph". It will likewise create a human relationship that "Alice" likes "Memgraph".

Adjacent, find the created nodes and relationships by executing this second query:

          MATCH (u:User)-[r]->(10) Return u, r, ten;                  

The query returns the following result:

          | u                      | r      | x                             | | ---------------------- | -------| ------------------------------| | (:User {name: "Alice"})| [Likes]| (:Software {name: "Memgraph"})|                  

Lastly, type :quit in the prompt to get out the mg_client tool.

Splendid! You accept now installed Memgraph and used its CLI tool to run a uncomplicated query.

Now, bated from a CLI tool, Memgraph also has an integrated development environment called Memgraph Lab to help you manage and execute various tasks on your databases. Permit's move on to the next step to install it.

Pace 3 — Installing Memgraph Lab and Connecting to Memgraph

Start past selecting and downloading the Memgraph Lab build for macOS from Memgraph's website Memgraph Lab Download page.

Once downloaded, installing the app on your system is similar to how you would install almost Mac apps — by opening the .dmg file and dragging the app (Memgraph Lab) into the /Applications folder.

Subsequently installing the app, run it.

Now, depending on your macOS' security preferences, information technology might block the app from running the showtime time. This is because information technology can't recognize the developer of the app, which in this case, is Memgraph.

This is normal and null yous should worry near. Just printing the "OK" push to dismiss the dialog box.

What you need to exercise next is to allow macOS to run Memgraph Lab. To practice this, open your system's Organisation Preferences so click Security & Privacy preferences.

Now, inside the Security & Privacy preference pane, ensure that the "General" tab is active and wait to the "Let apps downloaded from:" section. Any choice or setting that will let Memgraph Lab to run volition be available there.

For more information nigh allowing unidentified apps to run on macOS, come across the articles Open an app from an unidentified programmer and the Safely open apps on your Mac.

After updating your security preferences, try rerunning Memgraph Lab. But click "Open up" if macOS asks you if y'all really desire to open it. This is once again office of macOS' security precautions.

Memgraph Lab will now open, and you should be presented with the Abode screen. Using the default values of the "Host" and "Port" text fields, click "Connect" to start connecting to the Memgraph server. In the meantime, only leave the "Username" and "Password" fields blank.

Before connecting, ensure that the Memgraph server is running equally explained on Step ane. You lot won't be able to connect if the server is not running in the kickoff identify!

Once connected, y'all'll be presented with Memgraph Lab'south user interface.

Now that nosotros have Memgraph Lab installed and connected to Memgraph, we will run a few basic queries to make sure everything works properly.

Step 4 — Testing the Memgraph Lab Installation

Let'due south exam Memgraph Lab by running the same queries we ran in Stride 2.

  1. First, click the "Query" tab on the left sidebar.

  2. Next, enter this kickoff query at the query editor which is located at the top of the screen:

                  CREATE (u:User {name: "Alice"})-[:Likes]->(m:Software {proper noun: "Memgraph"});                          

    The query to a higher place creates 2 nodes and a relationship betwixt them.

  3. Lastly, click "Run" or press Cmd + Enter to execute the query.

If no error bulletin appeared, that means your query executed successfully. Again, this is the aforementioned query we ran in Step 2. Kindly refer back to it for its explanation.

Nosotros will now remember the nodes and relationships we've just created by executing the following Zilch query:

          Match (u:User)-[r]->(x) Return u, r, ten;                  

You should get a result that looks similar to this:

Memgraph Lab displaying the graph visualization of a query result.

You now have Memgraph Lab working correctly on your system. Memgraph Lab's visual presentation of query results is one of its all-time features. Information technology helps you empathize the relationships of your nodes compared to the tabular format presented past the mg_client tool we introduced in Step two. This makes Memgraph Lab the preferred tool for both beginners learning Memgraph and the Goose egg query language, and advanced Memgraph users working on complex queries.

Determination

In this tutorial, you installed Memgraph and Memgraph Lab on macOS. You tested the Memgraph installation by running a Memgraph server and using the mg_client CLI tool to execute Cypher queries against the server. The same goes for Memgraph Lab, simply instead of using the CLI tool, you ran the queries within the application.

If you are interested in learning more about each production, please consult the corresponding Memgraph and Memgraph Lab.

If you are new to Memgraph or graph databases in full general, finishing this tutorial marks an excellent starting point for farther learning and something you should build upon. Hither are our other tutorials you tin can follow:

  • Exploring the Marvel comic universe social network with Memgraph.
  • Exploring Game of Thrones deaths with Memgraph

If you take any questions or would like to get any help with Memgraph, delight check out our customs forum.

caffeyorms1954.blogspot.com

Source: https://memgraph.com/blog/how-to-install-memgraph-and-memgraph-lab-with-docker-on-macos

0 Response to "Testeach Inside Out and Back Again"

إرسال تعليق

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel