In this post I go through basic commands to install and configure: Mongodb, MySQL, Memcached and SQLite. The idea is to organize it in one place.

Install Homebrew ?

ruby -e "$(curl -fsSL"


Install MongoDB with Homebrew

brew update
brew install mongodb


Before you start mongod for the first time, you will need to create the data directory. By default, mongod writes data to the /data/db/ directory.

mkdir -p /data/db

Ensure that the user that runs the mongod process has read and write permissions to this directory.

chown 'id -u' /data/db


Start MongoDB with mongod and make a simple mongo connection with mongo (use nohup to start mongod and later close terminal...).

mongod --rest &
#create admin user
use admin
db.addUser( { user: "<username>",
          pwd: "<password>",
          roles: [ "userAdminAnyDatabase" ] } )

Install Admin Gui (ex. I really favour Robomongo)


Install MongoDB with Homebrew

brew update
brew install memcached


To start using memcached, start the memcached service on one or more servers. Running memcached sets up the server, allocates the memory and starts listening for connections from clients.

memcached -d -m 1024 -p 11211
#-m => Set the amount of memory allocated Default is 64MB.
#-p =>port  -d =>launch as daemon  

You can get around this by running multiple instances of memcached, each listening on a different port:

memcached -m 1024 -p11211
memcached -m 1024 -p11212
memcached -m 1024 -p11213
killall -c memcached


Install from .dmg

Download and open the MySQL package installer (.dmg)

 cd /var
 sudo mkdir mysql
 cd mysql
 ln -s /tmp/mysql.sock mysql.sock


  cd /usr/local/mysql/bin/

  #connection as user admin with all privileges
  mysql -uroot -p

  #create db
  mysql> CREATE DATABASE [dbnome];

  #create user grant privileges on single db
  mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  mysql> GRANT ALL PRIVILEGES ON dbTest.* To 'user'@'localhost' IDENTIFIED BY 'password';


cd /usr/local/mysql/support-files/
./mysql.server start
./mysql.server stop

#tips: in your bash file:
export PATH=/usr/local/mysql/bin:$PATH

alias mysql-start='/usr/local/mysql/support-        files/mysql.server start'

alias mysql-stop='/usr/local/mysql/support-        files/mysql.server stop'


Install sqlite with homebrew

brew install sqlite
#check version
sqlite3 -version
#create db file
sqlite3 mydbfile.db
#generic query 
sqlite3 -line mydbfile.db '[your query]'

© 2021. All Rights Reserved.

Ghostium Theme by @oswaldoacauan

published with Ghost

Privacy Policy