netstat -lanp | grep "27017"
/usr/local/mongodb/bin/mongod -dbpath=/usr/local/mongodb/data/db --fork --port 27017 --logpath=/usr/local/mongodb/log/work.log --logappend --auth
/usr/local/mongodb/bin/mongod -dbpath=/usr/local/mongodb/data/db --fork --port 27017 --logpath=/usr/local/mongodb/log/work.log --logappend --auth
[root@localhost shell]# vi start-mongodb.sh
MONGODIR=/usr/local/mongodb
MONGOD=$MONGODIR/bin/mongod
MONGO=$MONGODIR/bin/mongo
DBDIR=$MONGODIR/data/db
LOGPATH=$MONGODIR/log/mongodb.log
$MONGOD -dbpath=$DBDIR --fork --port 27017 --logpath=$LOGPATH --logappend --auth
// 根据手册,C#驱动下创建数据库及添加用户用这种方式
//string connectionString = "mongodb://admin:admin@localhost"
//// 连库语句
//MongoServer server = MongoServer.Create(connectionString);
//// 连库或创建一个数据库test
//MongoDatabase test = server.GetDatabase("test");
//// 加个用户进去
//MongoCredentials credentials = new MongoCredentials("username", "password");
//test.AddUser(credentials);
using (Mongo mongo = new Mongo("mongodb://test:[email protected]:27017/test"))
var db = mongo.GetDatabase("test");
MONGODIR = /usr/local/mongodb
MONGOD = $MONGODIR /bin/mongod
MONGO = $MONGODIR /bin/mongo
DBDIR = $MONGODIR /data/db
LOGPATH = $MONGODIR/log /work.log
# mongod will print its pid, so store it in out.tmp, then
# print it using awk to mongod.pid
$MONGOD --dbpath $DBDIR --fork --logpath $LOGPATH --logappend --auth