Mysql Tutorials and Examples

Enable query log without restarting mysql on Linux

Steps to enable mysql query log on mysql server without restarting mysql process on Ubuntu and other Linux flavours. Set general_log_file on SQL prompt: SET read more

How to find mysql query rate on Linux

Sometimes we want to know the current queries rate being sent to mysql server. This can be useful to get some idea on query load read more

Mysql – get total queries since beginning

Total queries on mysql prompt: mysql> SHOW STATUS like “Queries”; +—————+——–+ | Variable_name | Value | +—————+——–+ | Queries | 278583 | +—————+——–+ 1 row read more

Mysql – how to copy a table

Cloning table with indexes/triggers and data First create new table with same structure. We’ll use wordpress table wp_posts for the purpose of this tutorial. mysql> read more

Mysql – how to enable query log

It may be useful to enable mysql query log on development of even production server for a short duration for debugging or code/flow analysis purpose. read more

Mysql difference between CURDATE() and NOW()

Mysql CURDATE CURDATE() returns only date portion of date in current timezone. select CURDATE(); Outcome 2015-12-02 Mysql NOW NOW() returns full time in current timezone. read more

Mysql find current timezone offset

Print current local and global timezone SELECT @@global.time_zone, @@session.time_zone; Here is the outcome @@global.time_zone @@session.time_zone +05:30 +05:30 Find timezone offset using convert_tz select TIMEDIFF(now(), convert_tz(now(), read more

Mysql how to dump schema of all databases

It is a good idea to frequently take schema dump of all your databases. This may be useful in case there is some accidental change. read more