one of the most foolish steps under Ubuntu ( below are the actions under the root user ):
1. Run "apt-get install MONGO"
Run "apt-get update" If the installation package is not found
2. You should automatically run the Mongod program after you install it, and see if the process has started with "pgrep mongo-l ".
3. Enter "MONGO"in terminal, then enter the database
(over)
Here's how to start your own MongoDB program.
Two. Restart the system after the MONGO program to manually restart itself, the steps are as follows:
1. Run the "locate MONGO" command to see where the system defaults to the MONGO, which focuses on three things.
(1) One is called "mongod" The location of the program (he is equivalent to the MONGO database server, need to always run in the background, my path:/usr/bin/mongod);
(2) One is the location of the log log file of the MONGO database (loglog file to see the specific file name, the specific usage is described in the following, my path:/var/log/mongodb/mongodb.log);
(3) One is the location of the log log of the MONGO (my path:/var/log/mongodb/mongodb.log).
2. First enter the directory where the Mongod is located (/usr/bin/mongod), and then run "./mongod--dbpath/var/lib/mongodb/--logpath/var/log/ Mongodb/mongodb.log--logappend &"
--dbpath: Specifies which folder the MONGO database file is in
--logpath: Specify the log log of the MONGO, here log must be specified to the specific file name
--logappend: indicates that the log is written in an additional way, with the default overwrite of the previous file
&: indicates that the program is running in the background
Note: If the system is not properly shut down, so that the boot will be error, because MongoDB is automatically locked, it is necessary to enter the MongoDB database file directory (/var/lib/mongodb/), delete the directory Mongodb.lock file, and then do the above.
After installation, you can write a C + + program to do the corresponding database operations, write a simple connection MONGO C + + program and if the resolution of MONGO dynamic library link failure is described in another article.
Close/Start
sudo service mongodb stop sudo service mongodb start
To set the database connection password:
Creating a folder with directory: data/db
Close the existing service.
sudo service MongoDB stop
Restart Service
$ mongod–auth
Create a connected user
$ MONGO
>use Admin
Switched to DB admin
>db.adduser ("Root", "1983")
Close the service ( Command window launched directly in Mongod "Ctrl + C")
Restart Service:
$: Mongod–auth
To see if validation starts:,
$ MONGO
MongoDB Shell version:2.0.4
Connecting To:test
>use Admin
Switched to DB admin
>show Collections
Fri Mar 09:07:08 uncaught exception:error: {
"$err": "Unauthorized db:admin lock Type:-1 client:127.0.0.1",
"Code": 10057
}
There is a hint link error.
for user authentication:
>db.auth ("Root", "1983")
1
Re-view to view datasets
>show Collections
System.indexes
System.users
To set up a client connection:
The default installation allows only 127.0.0.1 IP connections .
The following records need to be modified /etc/mongodb.conf comments:
Open File:
$ sudo gedit/etc/mongodb.conf
Note Record:
#bind_ip = 0.0.0.0
MongoDB Remote Access configuration (Ubuntu)
1, first modify the MongoDB configuration file to listen to all the external network IP, if not, the connection will definitely have an exception
Edit file: vi/etc/mongodb.conf
The revised content is as follows:
Bind_ip = 0.0.0.0 or #bind_ip 127.0.0.1
Port = 27017
Auth=true (add account, password Authentication)
2,/etc/init.d/mongodb restart
3. Connection
#本地连接
/usr/local/mongodb/bin/mongo
#远程连接
/usr/local/mongodb/bin/mongo127.0.0.1/admin-u username-p Password
4. Add user access rights to a database
Db.adduser (' user ', ' pwd ')
Db.auth (' user ', ' pwd ')
5. Delete users
Db.removeuser (' username ')
Category: Bigdata Tags: mongodb
MongoDB installation Steps under Ubuntu