mongo 下载:https://www.mongodb.com/download-center/community?jmp=nav
创建目录,将下载的文件放在如下位置
xxx@ubuntu:/usr/local$ sudo mkdir mongo xxx@ubuntu:/usr/local$ ls bin etc games include lib man mongo sbin share src xxx@ubuntu:/usr/local$ cd mongo/ xxx@ubuntu:/usr/local/mongo$ ls mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz
解压
xxx@ubuntu:/usr/local/mongo$ sudo tar -xvf mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz xxx@ubuntu:/usr/local/mongo$ ls mongodb-linux-x86_64-ubuntu1404-4.0.5 mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz
创建数据库目录以及日志文件
xxx@ubuntu:/usr/local/mongo$ cd mongodb-linux-x86_64-ubuntu1404-4.0.5
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ sudo mkdir data
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ sudo touch logs
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ ls
bin logs MPL-2 data logs.2019-01-14T08-18-21 README LICENSE-Community.txt logs.2019-01-14T08-25-22 THIRD-PARTY-NOTICES
安装客户端
先下载这个文件,然后安装
sudo dpkg -i mongodb-org-shell_4.0.5_amd64.deb
进入到mongodb下面的bin里面查看mongodb帮助文档
./mongod -h
找到参数
--fork --dbpath arg --logpath arg --nohttpinterface
--dbpath=/usr/local/mongodb/data/ 用于指定存放的mongodb数据库
--fork 是后台执行,不然一直在前台
--logpath=/usr/local/mongodb/logs 用于指定mongodb的日志记录文件
启动数据库
sudo ./mongod --dbpath=/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5/data/ --logpath=/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5/logs
即可通过mongo命令进入数据库。
xxx@ubuntu:~/Desktop$ mongo MongoDB shell version v4.0.5 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("0783a892-c57e-4dee-94af-c3746762298a") } MongoDB server version: 4.0.5 Server has startup warnings: 2019-01-14T16:48:44.102+0800 I STORAGE [initandlisten] 2019-01-14T16:48:44.102+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2019-01-14T16:48:44.102+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-01-14T16:48:44.839+0800 I CONTROL [initandlisten] 2019-01-14T16:48:44.840+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-01-14T16:48:44.840+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-01-14T16:48:44.840+0800 I CONTROL [initandlisten] --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- >