Logging MySQL queries in table

Just came around a handy (i.e. Docker environment) logging feature of MariaDB.

Enable logging:

SET global general_log = 1;
SET global log_output = 'table';

 

View query log:

SELECT * FROM mysql.general_log
-- OR --
SELECT * FROM mysql.general_log ORDER BY event_time DESC

 

Disable logging:

SET global general_log = 0;
Advertisements

The Only Three Ways To Be More Productive

I’ve met plenty of people who have “five years of marketing experience” that can’t market as well as someone who has worked in marketing for six months but read the fundamental books of the field.

At the end of the day or week, make a list of your least valuable tasks and ask: “Is it profitable?” If not, stop doing it. If yes, can you delegate it?

From https://taylorpearson.me/3productivity/

Everything You’ve Been Taught About How To Read a Book Is Wrong

the main role of reading is improving your model of the world to more accurately reflect reality so that you can make better decisions.

The reason for reading a book is not to be able to spit back facts at a cocktail party — it’s to shape the way you think.

From https://taylorpearson.me/howtoreadabook/

Log mysql queries in Docker container

To log mariadb (mysql) SQL queries in a Docker container add - ./docker/mysql/conf.d:/etc/mysql/conf.d to volumes of the database service.

version: '3'

services:
   db:
     container_name: db
     image: mariadb:10.1
     volumes:
       - db_data:/var/lib/mysql
       - ./docker/mysql/conf.d:/etc/mysql/conf.d
     environment:
       MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'

volumes:
    db_data:

The contents of docker/mysql/conf.d/my.cnf

# docker/mysql/conf.d/my.cnf

[mysqld]
general_log = 1
general_log_file = /var/log/mysql/query.log

slow_query_log = 1
long_query_time = 1 # seconds
slow_query_log_file = /var/log/mysql/slow.log
log_queries_not_using_indexes = 0

 

Tried mitmproxy & mitmweb

Today I came by https://mitmproxy.org/ and gave it a shot just to know what it is capable of. For example for REST API communication debugging. The mitmweb is in beta, but looks good and also worked for me 🙂

The best is that they provide a docker image so trying it out was really simple.

  1. Just run docker run --rm -it -p 8080:8080 -p 8081:8081 --net="host" mitmproxy/mitmproxy mitmweb
  2. Open http://127.0.01:8081
  3. I changed Firefox to use proxy at 127.0.0.1 and port 8080 and browsed the web with mitmproxy intercepting the HTTP communication

mitmproxy & mitmweb

Put WordPress in maintenance mode without a plugin

1. In your web root directory (where the wp-config.php is located) create file .maintenance
2. It’s content should be <?php $upgrading = time();
3. You can customize the page by creating wp-content/maintenance.php

See source https://github.com/WordPress/WordPress/blob/9041e7a07150b10ed28ec274374ce7d397b0ac9b/wp-includes/load.php#L203-L206