Graceful view of MySQL GRANTS

Just found this script. It allows to output grants in graceful way:

mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'

Continue reading

How quickly to check time of mysql query by running it N times

After query optimization I just needed to run query several times to check time and compare it with original query. Query code was placed into query.sql file.

TIMEFORMAT=%R && for i in {1..10}; do time mysql < query.sql > /dev/null; done

Continue reading