I created /data/db in root directory and ran ./mongod:
[initandlisten] exception in initAndListen: 20 Attempted to create a lock fi
If you do not need to have the database directories in root, you can create data/db in your home directory (mkdir -p ~/data/db).
Then you can start the MongoDB server with the --dbpath option:
mongod --dbpath=$(echo ~)/data/db
(This is assuming you're starting it from a terminal. For some strange reason, mongod does not accept ~ as the home directory path, hence the bash echo substitution trickery, you may as well write /home/yourusername/data/db)
In fact, it does not have to be ~/data/db, it can be anywhere you want and this way you can have multiple database paths and organize everything nicely. May not be the best option for production (depending on what you want to do), but for developing works fine.