更新时间:2021-12-12 02:52:53
sudo apt-get purge mongodb-org*
只需从此处重新开始.
如果您不想要3.2,请不要
If you don't want 3.2, do not
sudo apt-get install -y mongodb-org
在下一步中指定所有单个组件的版本.
Specify the version for all the individual components in the next step.
或者您可以从 mongodb 复制正确的版本链接.
OR you can copy the correct version link from mongodb.
您将需要
cd /Downloads
wget wget https://fastdl.mongodb.org/linux/mongodb-correct-version.tgz
tar -zxvf mongodb-correct-version.tgz
您应该看到所有可执行文件. 确保/usr/local/bin在您的PATH中
You should see all the executables. Make sure /usr/local/bin is in your PATH
echo $PATH
为mongod服务器创建符号链接并检查版本.
Create a symbolic link for the mongod server and check the version.
sudo ln -s ~/Downloads/mongodb-correct-version/bin/mongod /usr/local/sbin/bin/mongod
mongod --version
现在为外壳创建一个符号链接并检查版本.
Now create a symbolic link for the shell and check the version.
sudo ln -s ~/Downloads/mongodb-correct-version/bin/mongo /usr/local/bin/mongo
mongo --version
为服务器创建目录路径.
Create a directory path for the server.
mkdir ~/data
mkdir ~/data/db
启动服务器,并使其从不同于Shell的单独终端运行.
Start the server and let it run from a separate terminal than the shell.
mongod --dbpath ~/data/db/
它应该在端口27017上侦听. 在新的终端中,启动mongo.
It should be listening on port 27017. In a new terminal, start mongo.
mongo