Skip to content

Instantly share code, notes, and snippets.

@hacker0limbo
Last active August 22, 2019 12:33
Show Gist options
  • Select an option

  • Save hacker0limbo/cf64f0365f7e1fa2cd8b3ccd23c38ead to your computer and use it in GitHub Desktop.

Select an option

Save hacker0limbo/cf64f0365f7e1fa2cd8b3ccd23c38ead to your computer and use it in GitHub Desktop.
软件安装的一些操作

mongodb

安装

使用homebrew安装, 安装以后需要配置环境变量, 在.bash_profile.zshrc里面加上export PATH=/usr/local/Cellar/mongodb/4.0.3_1/bin:$PATH, 然后source使文件生效. 同时需要在 root 目录下新建数据目录, 如下:

mkdir -p /data/db

安装过程中出现的一些错误:

  • /data/db 访问权限, 使用sudo chmod -R 0777 /data/db赋予权限
  • 端口占用, mongodb使用27017, 使用lsof -i:27017查看占用的端口, sudo killall -15 mongod清除所有的端口(注意不要使用kill -9 <PID>)
  • mongod --repair来修复错误
  • sudo service mongod start 开启服务器

启动:

mongod # 用来开启服务器
mongo # 用来启动 mongodDB shell, 命令行客户端

停止:

Ctrl-c 停止 mongod 进程

pgrep mongo // 得到进程 id 以后
kill <id>

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment