Set up mongodb on Linux operating system
Introduction | MongoDB is a product between a relational database and a non-relational database. It is the most feature-rich among non-relational databases and is most like a relational database. The data structure it supports is very loose and is a bson format similar to json, so it can store more complex data types. The biggest feature of Mongo is that the query language it supports is very powerful. Its syntax is somewhat similar to an object-oriented query language. It can almost implement most functions similar to single-table queries in relational databases, and it also supports indexing of data. |
As shown below, place it in a certain corner of the local area. Remember the location~
ssh root@你的IP //回车输入密码3. Installation package upload
Open another ssh window (command n). If it is windows, open a new cmd window. Because we want to operate local files, we have already logged in to the server in the previous window. There are many ways to pass, I will only demonstrate one of them.
cd "The folder where the installation package is located" //Go to the location where you just placed the installation package<br>
scp "local file" root@yourIP // Enter and enter the password to start transmission
As shown below, I transferred it to the root directory of the server. In fact, it is not recommended. You can put it in an inherent directory, such as /usr/local
ls -l //Expand in list form, we can see that the download has been successful.
tar -zxvf mongodb-linux-x86_64-3.4.6.tgz //Decompression Different files have different decompression commands, you can use Baidu yourself
I just said that you can put the stuff you install each time into a fixed folder, so I moved the unzipped files to the /usr/local/mongodb directory. If you have already put it in the location you like, you can Skip this step. If you don’t know how to move, you can take a look.
cd /user/local //Enter local<br>
mkdir mongodb //Create mongodb folder<br>
cd / //Enter the root directory<br>
mv mongodb-linux-x86_64-3.4.6 /usr/local/mongodb /*Move the decompressed package just now into /usr/local/mongodb*/
mkdir data //创建data文件夹,存放数据库db文件 mkdir logs //创建logs文件夹,存放日志文件 cd logs //进入logs touch mongo.log //创建log文件 cd .. //返回上一级 mkdir etc //创建配置文件夹 cd etc // 进入etc vim mongo.conf //编辑同时创建mongo.conf 文件
The following is the code in the mongo.conf file. Be careful not to make mistakes. After entering the file, you must press i on the keyboard to start writing code.
dbpath = /usr/local/mongodb/data //路径一定要输入绝对的 logpath = /usr/local/mongodb/logs/mongo.log //路径一定要输入绝对的 logappend = true journal = true quiet = true port = 27017 //端口
After writing, press the esc key to exit, then press shift: it will appear at the bottom: Then enter wq, save and exit.
At this point it's almost the end.
cd mongodb/mongodb-linux-x86_64-3.4.6/bin //进入安装包的bin目录下 mongod -f /usr/local/mongodb/etc/mongo.conf //启动1方法 或 ./mongod -f /usr/local/mongodb/etc/mongo.conf //启动2方法
If you enter this command, the following picture will appear. There is no change, only the cursor flashes.
The visualization tool I use is Robo 3t. Create a new link, enter the server address as address, and fill in the port configured in your mongo.conf, which is basically 27027.
Click Save and proceed as shown below to connect.
If you get to this step, it's basically a success.
I previously wrote the path in mongo.conf relative, and the following problem occurred.
Then it looks like this.
There are many methods, I wrote only one of them, and it is my first time to install it. There are some pitfalls in it. Don’t admit defeat when you encounter problems, they will always be solved. If I write something wrong or bad, I hope you will give me some advice~
The above is the detailed content of Set up mongodb on Linux operating system. For more information, please follow other related articles on the PHP Chinese website!

Artificial Intelligence (AI) is a term that’s been buzzing around for a while now, from self-driving cars to voice assistants like Siri and Alexa, AI is becoming a part of our everyday lives. But what exactly is AI, and why should Linux users care ab


For someone new to Linux, using it can still feel challenging, even with user-friendly distributions like Ubuntu and Mint. While these distributions simplify many tasks, some manual configuration is often required, but fully harnessing the power of L

In the previous article, we introduced the basics of AI and how it fits into the world of Linux. Now, it’s time to dive deeper and set up your Linux system to start building your first AI model. Whether you’re a complete beginner or have some exper

If you’re looking to manage your server with ease, Kloxo is a great option, as it is free and open-source web hosting control panel that allows you to manage your server and websites with a simple, user-friendly interface. In this guide, we’ll walk

If you’ve ever found yourself in a situation where you’re trying to move a bunch of files and folders, only to be stumped by spaces in the folder names, you’re not alone. Spaces in filenames or folder names can quickly become a frustrat

The KDE Plasma desktop is renowned for its sleek design, extensive customization options, and impressive performance. For users who appreciate a polished, modern interface with the flexibility to tweak every detail, Plasma is a dream come true. But w


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
