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 https://raw.github.com/Homebrew/homebrew/go/install)"

Mongodb

Install MongoDB with Homebrew

brew update
brew install mongodb

Configure

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/STOP

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

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

Install Admin Gui (ex. I really favour Robomongo)

Memcached

Install MongoDB with Homebrew

brew update
brew install memcached

START/STOP

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:

#start
memcached -m 1024 -p11211
memcached -m 1024 -p11212
memcached -m 1024 -p11213
#stop
killall -c memcached

MYSQL

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

configure

  cd /usr/local/mysql/bin/
  ./mysql_secure_installation

  #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';

START/STOP

cd /usr/local/mysql/support-files/
#start
./mysql.server start
#stop
./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'

SQLite3

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]'

© 2018. All Rights Reserved.

Ghostium Theme by @oswaldoacauan

published with Ghost

Privacy Policy