First of all, make sure your dbpath exists.
mkdir -p ~/data/db
Then start mongod with:
mongod --dbpath ~/data/db
Finally:
mongo
EDIT: I saw some people vote this answer up. To make it clear, this solution is for you to start mongod with command line. Most of the time if you installed MongoDB package from source, you can just start the daemon with:
sudo systemctl start mongodb # Arch linux
sudo service mongod start # CentOS/Redhat
Configuration file can be found in:
vim /etc/mongod.conf
And if you want daemon to be auto started from boot,
sudo systemctl enable mongodb # Arch Linux
sudo chkconfig mongod on # CentOS/Redhat
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…