Mysql Tutorials and Examples

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

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 – get total queries since beginning

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

WordPress mysql query to get all custom keys and values for a post

Handy mysql query to get all custom keys and values for a post in wordpress. SELECT wp_postmeta.* FROM wp_postmeta JOIN wp_posts ON wp_posts.ID = wp_postmeta.post_id 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

How to delete orphan wordpress wp_postmeta rows

WordPress keeps the post meta values in wp_postmeta table. When a post is deleted, its meta data may become orphan. It is harmless data but 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

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

migrate multiple mysql databases using mysqldump on Linux

Sometimes we need to migrate all mysql databases to a new machine. This can be the case when you are migrating your multiple wordpress blogs read more

How to fix mysql service stopping intermittently on AWS micro instance

I was having this problem since last few days. My mysql server was getting killed on its own on aws/ec2 micro instance. So far I read more

How to connect to mysql server using ssh port forwarding

When mysql server is hosted on a cloud environment like amazon aws/ec2 or rackspace, connecting to it using mysql GUI tools may not be possible without read more

How to allow mysql access on AWS/EC2 from another instance

When you take two AWS EC2 instances, you may need remote mysql access from one AWS instance to another instance. Here are the steps to read more