Skip to content

Instantly share code, notes, and snippets.

@CodeKiwi
Created April 20, 2016 03:48
Show Gist options
  • Save CodeKiwi/f07fd4a73ae4523b8d10bc4d0cdb40f7 to your computer and use it in GitHub Desktop.
Save CodeKiwi/f07fd4a73ae4523b8d10bc4d0cdb40f7 to your computer and use it in GitHub Desktop.
#Logs into MySQL with root account and asks password
mysql -u root -p
#Show the items for the selected type
show databases|tables|columns in <table>
#Show count of articles older than 30 days
SELECT COUNT(*) FROM articles WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
#Delete articles older than 30 days
DELETE FROM articles WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
#Show size of tables
SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "dyor_data";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment