mysqldump -u {user} -p {database} | gzip > {database}.sql.gz
gzip -dc < {database}.sql.gz | mysql -u {user} -p {database}
Convert DateTime in UnixTimeStamp
SELECT *,from_unixtime(date_added) FROM
TABLE_NAME order by date_added desc
Space consume by a table
SELECT table_schema "Data Base Name",sum( data_length + index_length ) / 1024 / 1024 /1024 "Used GB" FROM information_schema.TABLES GROUP BY table_schema ;
Character Set
utf8mb4_unicode_ci
Set a login path using terminal/putty
Getting started:
Related tutorials:
========================================================================================================== | |
MySQL Guide - Basics | |
========================================================================================================== | |
Connect/Disconnect from MySQL Server | |
---------------------------------------------------------------------------------------------------------- | |
:~ sudo mysqld_safe //Turns on MySQL server | |
:~ mysql -h host -u root -p //Connects to MySQL server: "no need to specify host on local" | |
mysql> quit; //Disconnects from MySQL | |
:~ mysqladmin -u root -p shutdown //Shuts down MySQL server | |
---------------------------------------------------------------------------------------------------------- |
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120) | |
FROM information_schema.processlist | |
WHERE command <> 'Sleep' | |
AND info NOT LIKE '%PROCESSLIST%' | |
ORDER BY time DESC LIMIT 50; |
This should be a short (4-5 sentences) blurb which succinctly describes the event. At the very least, it should include:
…which lasted for roughly 10 minutes between 9:02PM and 9:12PM Pacific…
# HAProxy configuration - haproxy-db.cfg | |
## | |
## FRONTEND ## | |
## | |
# Load-balanced IPs for DB writes and reads | |
# | |
frontend db_write | |
bind 172.16.0.50:3306 |
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |