Grant remote access permission to MySQL server

Login to your mysql/mariadb console:

sudo mysql -u <user> -p

Run this command:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YoUrP45sw0rd!' WITH GRANT OPTION;

Don’t forget to flush the privileges

FLUSH PRIVILEGES;

If user still cannot see the tables, try to disconnect mysql and reconnect again.

Make paging output from your python script

pydoc is a python library to make your console output paginates for easier reading. to use it follow the simple example below:

import pydoc

text = "...paginate me..."
pager = pydoc.ttypager(text)
print pager

you will see the output is gonna be truncated at the beginning when you start to see like when you open up a man page, then you have to scroll down with keyboard to read the rest of the text line by line. pretty cool!

How to find out what application that using specific port

Just a case if you want to know some application or service who is running under specific port :

$ netstat -tulpn | grep :80

Sometimes you need to run with sudo to see all services :

$ sudo netstat -tulpn | grep :80

Output :

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1393/nginx.conf

It turns out that 1393 is the pid of service

Docker command cheatsheet

docker build image

$ sudo docker build -t image-name .

docker to start a container from image

$ sudo docker run -itd --name jenkins --publish 8080:8080 --publish 50000:50000 jenkins

docker to get inside the container

$ sudo docker exec -it jenkins bash

docker stop container

$ sudo docker stop image-id/name

docker remove container

$ sudo docker rm image-id/name

docker remove containers based on specific image name/tag

sudo docker ps -a | awk '{ print $1,$2 }' | grep centos:7 | awk '{print $1 }' | xargs -I {} sudo docker rm {}

docker remove image

$ sudo docker rmi image-id

docker remove images with no tag

$ sudo docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)

WordPress still cannot Establishing a Database Connection – Error

Have you ever experiencing this problem like this? after your install wordpress, setup anything, webserver, database, everything is completed. Yet, wordpress still cannot establishing your database connection.

Eventhough you’ve already make sure that your database is up and running (I’m using MySQL) and your port is already open, though.

Trust me! I’ve done anything properly, I spent hours just to figure out what the root cause was and after some googling and stackoverflowing, I found this problem was due to SE in linux.

$ sudo setsebool -P httpd_can_network_connect_db=1

Thanks in advance SElinux!