MongoDB simple installation and basic operation of the Linux system

This article describes a simple installation and basic operation of MongoDB on Linux systems, you need friends can refer to the following
 

Mongo DB, is currently in the IT industry is very popular as a non-relational database (NoSql), its flexible data storage, much favored by the current IT practitioners. Mongo DB achieved a very good idea of ​​object-oriented (OO thinking), in Mongo DB in each record is a Document object. Mongo DB biggest advantage is that all the data persistence operations without having to manually developers to write SQL statements directly call the method can easily implement CRUD operations.

First, download mongodb

Go to the download page mongodb official website: https://www.mongodb.org/downloads download the appropriate version, such as the current Linux x64 bit latest version: mongodb-linux-x86_64-2.6.4.tgz

But a little pit father is, obviously tgz format download link, download the results into a gz format:

 

First download and see better.

Second, unzip mongodb

1
[root@test6 ~]# gzip -d mongodb-linux-x86_64-2.6.4.gz

Get is mongodb-linux-x86_64-2.6.4, is actually a file, not a folder, and the Internet, said very different:

 

It seems there are problems with the previously downloaded! In fact, it should be the tgz file fishes, according to empirical analysis of what, in fact downloaded file or tgz, gz file appears as illusion only formal! So, gzip only to decompress the archive of the outer layer, a layer of tar actually need to unpack the archive attribute!

So, first unzip the file after renaming plus tar format:

1
[root@test6 ~]# mv mongodb-linux-x86_64-2.6.4 mongodb-linux-x86_64-2.6.4.tar

Then, use the tar can extract:

1
[root@test6 ~]# tar xvf mongodb-linux-x86_64-2.6.4.tar

 

After extracting the file folder & rename moved to / usr / local / mongodb

1
2
3
[root@test6 ~]# mv mongodb-linux-x86_64-2.6.4 /usr/ local /mongodb
[root@test6 ~]# cd /usr/ local /mongodb/bin/
[root@test6 ~]# ll

 

mongod the bin is MongoDB server-side process, mongo is its client, the other commands used for other purposes such as MongoDB MongoDB file export and so on.

Third, start mongodb
before the start, the first designated mongodb the data directory, if not create one:

12
[root@test6 ~]# cd /usr/ local /mongodb
[root@test6 mongodb]# mkdir data

Then, execute the following command to start mongodb:

1
[root@test6 mongodb]# /usr/ local /mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/ --logpath=/usr/local/mongodb/data/mongodb.log --logappend&

 

 

After a successful start, to see whether the success of the launch, the default port number is 27017, of course, you can also specify other unused port at startup.

 

Finally, the client mogo files in / bin under the soft link, easy to perform everywhere:

1
ln -s /usr/ local /mongodb/bin/mongo /bin/mongo

 

Now use the mongo client access at the database:

Guess you like

Origin www.cnblogs.com/zping/p/11133236.html