我正在尝试使用 osx 玩 mongodb,为此我需要在我的 mongodb exe 目录中使用以下内容创建一个目录
mkdir /data/db
但是,当我尝试这样做时,我的命令提示符返回以下内容
$ mkdir /data/db
mkdir: /data: No such file or directory
目前我的 mongodb exe 没有启用命令行,也就是说它不在 bash 的路径中,有谁知道如何使 mongodb 程序全局化?
提前致谢
添加所以我尝试添加 bash 文件,和
$ sudo mkdir -p /data/db/
$ mkdir -p /data/db
只需键入
$ mongod
仍然不起作用,我必须输入以下内容
$ ./mongod
但它给出了以下内容
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 13:27:37.558 [initandlisten] MongoDB starting : pid=1042 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 13:27:37.559 [initandlisten]
Thu Jul 18 13:27:37.559 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 13:27:37.559 [initandlisten] db version v2.4.5
Thu Jul 18 13:27:37.559 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 13:27:37.559 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu- 1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 13:27:37.559 [initandlisten] allocator: system
Thu Jul 18 13:27:37.559 [initandlisten] options: {}
Thu Jul 18 13:27:37.559 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 13:27:37.559 dbexit:
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: final commit...
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: closing all files...
Thu Jul 18 13:27:37.559 [initandlisten] closeAllFiles() finished
Thu Jul 18 13:27:37.559 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 13:27:37.559 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 13:27:37.559 dbexit: really exiting now
编辑2:
试过了
sudo chown 'myusername' /data/db
sudo ./mongod 或 ./mongod 都不是
工作过
编辑3:
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:11:35.144 [initandlisten] MongoDB starting : pid=1550 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:11:35.145 [initandlisten]
Thu Jul 18 14:11:35.145 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:11:35.145 [initandlisten] db version v2.4.5
Thu Jul 18 14:11:35.145 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:11:35.145 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:11:35.145 [initandlisten] allocator: system
Thu Jul 18 14:11:35.145 [initandlisten] options: {}
Thu Jul 18 14:11:35.145 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 14:11:35.145 dbexit:
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: final commit...
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:11:35.145 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:11:35.145 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:11:35.145 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 14:11:35.145 dbexit: really exiting now
$ sudo ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:11:43.450 [initandlisten] MongoDB starting : pid=1552 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:11:43.451 [initandlisten]
Thu Jul 18 14:11:43.451 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:11:43.451 [initandlisten] db version v2.4.5
Thu Jul 18 14:11:43.451 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:11:43.451 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:11:43.451 [initandlisten] allocator: system
Thu Jul 18 14:11:43.451 [initandlisten] options: {}
Thu Jul 18 14:11:43.451 [initandlisten] journal dir=/data/db/journal
Thu Jul 18 14:11:43.451 [initandlisten] recover : no journal files present, no recovery needed
Thu Jul 18 14:11:43.489 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
Thu Jul 18 14:11:43.489 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:28017
Thu Jul 18 14:11:43.489 [initandlisten] ERROR: addr already in use
Thu Jul 18 14:11:43.489 [websvr] ERROR: addr already in use
Thu Jul 18 14:11:43.489 [initandlisten] now exiting
Thu Jul 18 14:11:43.489 dbexit:
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:11:43.489 [initandlisten] shutdown: final commit...
Thu Jul 18 14:11:43.500 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:11:43.505 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:11:43.505 [initandlisten] journalCleanup...
Thu Jul 18 14:11:43.505 [initandlisten] removeJournalFiles
Thu Jul 18 14:11:43.506 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:11:43.506 dbexit: really exiting now
编辑4:
$ sudo killall mongod
Password:
$ sudo rm -rf /data/db
$ sudo mkdir -p /data/db
$ sudo chown xxxxx/data/db
usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...
chown [-fhv] [-R [-H | -L | -P]] :group file ...
$ ./mongod
./mongod --help for help and startup options
Thu Jul 18 14:27:04.047 [initandlisten] MongoDB starting : pid=417 port=27017 dbpath=/data/db/ 64-bit host=unknown20c9d0b97f55.att.net
Thu Jul 18 14:27:04.047 [initandlisten]
Thu Jul 18 14:27:04.047 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Thu Jul 18 14:27:04.047 [initandlisten] db version v2.4.5
Thu Jul 18 14:27:04.047 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Thu Jul 18 14:27:04.047 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Thu Jul 18 14:27:04.047 [initandlisten] allocator: system
Thu Jul 18 14:27:04.047 [initandlisten] options: {}
Thu Jul 18 14:27:04.110 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Jul 18 14:27:04.110 dbexit:
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to close listening sockets...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to flush diaglog...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: going to close sockets...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: lock for final commit...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: final commit...
Thu Jul 18 14:27:04.110 [initandlisten] shutdown: closing all files...
Thu Jul 18 14:27:04.119 [initandlisten] closeAllFiles() finished
Thu Jul 18 14:27:04.119 [initandlisten] shutdown: removing fs lock...
Thu Jul 18 14:27:04.119 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Jul 18 14:27:04.119 dbexit: really exiting now