I. the dumbest steps in Ubuntu (the following operations are performed under the root user): 1. run "apt-getinstallmongo". If the installation package cannot be found, Run "apt-getupdate" 2. after installation, the mongod program should be automatically run. Run "pgrepmongo-l" to check whether the process has been started. 3. enter "mongo" on the terminal and press enter to enter the database (
1. the dumbest steps in Ubuntu (The following areRootPerform operations under the user):
1. Run"Apt-get install mongo"
If the installation package cannot be found, run"Apt-get update"
2. After installation, the mongod program should be automatically run"Pgrep mongo-l"Check whether the process has been started
3. Enter"Mongo"And press enter to enter the database.
(Over)
The following describes how to start the mongodb program on your own.
2. After the system is restarted, the mongo program needs to be manually started. The steps are as follows:
1. Run"Locate mongo"Command to check where mongo is installed by default. Here, we mainly focus on three things.
(1) One is named"MongodThe location of the Program (which is equivalent to the Server of the mongo database and must be running in the background all the time. My path:/Usr/bin/mongod);
(2) The location of the log file of the mongo database (Log FilesTo view the specific file name, The specific usage will be introduced later, my path:/Var/log/mongodb. log);
(3) The location of the mongo log (my path:/Var/log/mongodb. log).
2. first enter the directory where mongod is located (/Usr/bin/mongod), And then run"./Mongod -- dbpath/var/lib/mongodb/-- logpath/var/log/mongodb. log -- logappend &"
-- Dbpath:Specifies the folder in which mongo database files are stored.
-- Logpath:Specify the log of mongo. Here, the log must specify the specific file name.
-- Logappend:Indicates that the log is written in an additional way. By default, the previous file is overwritten.
&:Indicates that the program runs in the background
Note:If the system is shut down abnormally, an error will be reported during startup. Because mongodb is automatically locked, This is the directory where the mongodb database file is located (/Var/lib/mongodb/), DeleteMongodb. lockFile, and then perform the preceding operations.
After installation, you can write a C ++ program to perform database operations, write a simple C ++ program to connect to mongo and introduce it in another article if mongo dynamic library link fails, see http://www.linuxidc.com/Linux/2011-12/48834.htm