安装mongodb后,在命令行进入mongoDB安装目录执行如下:
mongod --dbpath [数据存放的本地路径]
提示如下错误:
ERROR: dbpath (数据存放的本地路径) does not exist.
执行mongod --help,发现说明如下:
--dbpath arg (=\data\db\) directory for datafiles - defaults to \data\db\
于是加了个等号,执行命令为:
mongod --dbpath=[数据存放的本地路径]
还是提示一样的错误:
ERROR: dbpath (数据存放的本地路径) does not exist.
仔细检查发现路径上有中文字母,然后尝试把中文的路径修改成英文的之后,再次执行以上命令,就没再出现如上的错误了。
如果目录里包含有中文字符,执行完mongod --dbpath 命令之后再执行mongo命令来启动服务的时候,会出现如下错误:
C:\Program Files\MongoDB 2.6 Standard\bin>mongo MongoDB shell version: 2.6.0 connecting to: test 2014-05-05T15:02:40.588+0800 warning: Failed to connect to 127.0.0.1:27017, reas on: errno:10061 No connection could be made because the target machine actively refused it. 2014-05-05T15:02:40.591+0800 Error: couldn‘t connect to server 127.0.0.1:27017 ( 127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146 exception: connect failed
而且对应的路径下根本没生成任何东西。