Skip to content

MySQL By Example

Backup

Percona - All Databases

  • $ innobackupex --user=root --password= --socket=/var/run/percona/percona.sock ~/destination-dir-name/
    
  • $ innobackupex --user=root --password= --socket=/var/run/percona/percona.sock --apply-log ~/destination-dir-name/2017-06-26_06-58-21/
    

Total Usage Count

SELECT
    importexports_channels.channel_id,
    channels.name,
    channels.call_sign,
    count(channel_id) AS usage_count   
FROM 
    importexports_channels
LEFT OUTER JOIN
    channels ON importexports_channels.channel_id=channels.id
WHERE channel_id > 0   
GROUP BY channel_id

Total Sum Count

Calculate the sum of the total count of qty. In this example this returns the total duplicate records found by grouping them together.

SELECT SUM(qty) FROM (SELECT 
    COUNT(*) as qty
FROM
    dbname.programs_credits
GROUP BY 
    programs_id , programs_credits_names_id, programs_roles_id
HAVING 
    qty > 1) AS q