List of topics: MongoDB Linux Navicat

Download the MongoDB installation package to the local PC and upload it to the cloud server using XShell

Or download the corresponding file directly in the specified folder, in this case, /usr/mongodb

The curl - O https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.4.tgzCopy the code

Then unpack

Tar - ZXVF mongo - Linux - aarch64 - rhel82-4.4.4. TGZCopy the code

Then create folders, log files and Mongo configuration files under the current folder

Create folder data, folder logs, configure file mongodb. Conf, and create log file mongod

mkdir data
mkdir logs
touch mongodb.conf
cd logs
touch mongodb.log
Copy the code

Then use vim to modify mongodb.conf in the mongodb folder

Dbpath # database path = / usr/mongo/data # logpath log output file path = / usr/mongo/logs/mongod log # error log using append mode logappend = true # enable log files, With journal=true enabled by default, this option filters out unwanted log information. Default: 27017 Port =27017 # Allow remote access Bind_IP =0.0.0.0 # Enable child process fork=true # Enable authentication. Add user #auth=true firstCopy the code

Then go to bin and start MongoDB

./mongod --config /usr/mongodb/mongodb.conf
Copy the code

Run error found

-bash: ./mongod: cannot execute binary file: Exec format error
Copy the code

It was found that the installed version did not match the system version. Therefore, download the correct version again, decompress it, and run the preceding command in bin

The successful running

To disable MongoDB, run the following command

./mongod -shutdown -dbpath=/usr/mongodb/data
Copy the code

Then add the mongodb service to the environment variables and use Mongo anywhere to manipulate the database

Vi/etc/profile # # under the root directory of the etc in the last line to join the export PATH = $PATH: / usr/local/mongo/bin # PATH is you bin directory under the installation directory: the wq # save exitCopy the code

And then put it into effect

source profile
Copy the code

And then to make it remotely accessible, in sbin/

Execute the command

iptables -I INPUT -p tcp --dport 27017 -j ACCEPT
Copy the code

Next, access the address in your browser

It means success

Next, in order to facilitate management, I need to remotely connect to MongoDB on the cloud server through Navicat on my local machine

Check whether the firewall has developed port 27017: Firewall-cmd --query-port=27017/ TCP Firewall-cmd --permanent --add-port=27017/ TCP Reloading the firewall firewall-cmd --reload you can use the command above to view the port.Copy the code

You’d better turn on a firewall if you don’t have one

Then click test, you can connect successfully