How to install mongodb on linux
Installation method: 1. Download the installation package from the MongoDB official website; 2. Use tar and mv commands to extract the installation package to the specified directory; 3. Open the configuration file and add "export PATH" information; 4. Use the mkdir command to create the data storage directory and log file directory, and use the chown command to set read and write permissions.
The operating environment of this tutorial: Ubuntu 18.04 system, Dell G3 computer.
Download MongoDB
Go to the MongoDB official website (https://www.mongodb.com/try/download/community) to download the appropriate installation It’s packaged, as shown in the picture below:
After we select the installation package we want to use, we don’t need to download it directly in the browser, we just need to copy the download link. That’s it, then use Linux commands to download the MongoDB installation package, as shown below:
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.3.tgz
Install MongoDB
Relative to Installing MongoDB under Windows is much simpler and only requires a few simple steps to install MongoDB under Linux.
[Step 1] Unzip the downloaded installation package and move the unzipped files to the specified directory, the command is as follows:
tar -zxvf mongodb-linux-x86_64-rhel70-4.4.3.tgz # 解压 mv mongodb-src-r4.4.3 /usr/local/mongodb # 将解压后的文件拷贝到指定目录
[ Step 2] Modify the configuration file
Open the system configuration file, the command is as follows:
sudo vi /etc/profile
Next, press i or insert key in the vim editor to enter insert mode Edit the system configuration file and add the following configuration information in the configuration file:
export PATH = <directory>/bin:$PATH
where
export PATH=/usr/local/mongodb4/bin:$PATH
After editing, press the esc key to exit the insert mode, then press the shift : key and enter wq to save and exit the system configuration file.
After the system configuration file is successfully saved, you can use the following command to make the configuration file take effect:
source /etc/profile
[Step 3] Create the database directory
Default After MongoDB is started, the following two directories will be initialized:
Data storage directory: /var/lib/mongodb
Log file directory: / var/log/mongodb
So we can create these two directories and set read and write permissions before starting MongoDB, naming them as follows:
sudo mkdir -p /var/lib/mongodb sudo mkdir -p /var/log/mongodb sudo chown `whoami` /var/lib/mongodb # 设置权限 sudo chown `whoami` /var/log/mongodb # 设置权限
where mkdir -p The command is used to ensure that the directory name exists, and if it does not exist, create it. The chown `whoami` command is used to specify the file owner as the user himself, and whoami is a command to display his own name.
After completing the above steps, the MongoDB installation is complete!
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to install mongodb on linux. For more information, please follow other related articles on the PHP Chinese website!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)
