[TOC] ## Quick reference for Mysql commands: ### Remove all entries from a table: :::mysql DELETE FROM `Table`; or :::mysql TRUNCATE TABLE `Table`; ### Delete all soft-deleted items from table :::mysql DELETE FROM `Table` WHERE `deletedAt` IS NOT NULL; ### Delete or select things matching a pattern :::mysql SELECT * FROM Accounts WHERE Username LIKE '%mario%' ### Order results by updatedAt column `order by updatedAt;` :::mysql select * from `Task` order by updatedAt; ### Update field ```sql update `User` set subscribed=1 where email='[email protected]'; ``` Database Copying ------------------ Add this to your rc file: ``` alias ssh-db='mysql --defaults-extra-file=[Your path to your login config]/config.cnf' alias mysqldump-loggedin='mysqldump --defaults-extra-file=[Your path to your login config]/config.cnf' ``` Create a config.cnf file that contains your mysql credentials, something like this: ``` [client] user = ... password = ... host = ... ``` ### Copy Copy the old db: `mysqldump-loggedin olddatabasename > db.sql` ### Paste to new database Log into mysql, create a database: `create database newdbname` Log out, copy database record file to new database: `ssh-db newdbname < db.sql` ## A more in-depth reference I made [https://docs.google.com/document/d/1SYgWD-lg5tD26FRY6WxCIT-WbKLySIUOi7y7kRGz_0k](https://docs.google.com/document/d/1SYgWD-lg5tD26FRY6WxCIT-WbKLySIUOi7y7kRGz_0k)