Skip to content

Instantly share code, notes, and snippets.

View gustavobgama's full-sized avatar
🏠
Working from home

Gustavo Gama gustavobgama

🏠
Working from home
View GitHub Profile
@gustavobgama
gustavobgama / ShowMyIsamTables.sql
Last active December 16, 2015 02:29
How to show MyIsam tables
SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.TABLES WHERE ENGINE LIKE 'myisam';
@gustavobgama
gustavobgama / ViewSizeOfDir
Created May 7, 2013 19:17
View used size of directory
du -hs /path/to/folder
@gustavobgama
gustavobgama / MySQLShowProcessList
Created May 28, 2013 13:23
Show mysql processlist with periodical refresh
watch -n1 'mysql --user=user --password=password database --execute="SHOW PROCESSLIST"'
@gustavobgama
gustavobgama / createDatabase.sh
Created September 19, 2013 21:06
Create database
mysql --user=user --password=password -e 'CREATE DATABASE IF NOT EXISTS db_name DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'
@gustavobgama
gustavobgama / clearQueryCache.sql
Created September 24, 2013 12:07
Clear MySQL query cache
RESET QUERY CACHE;
@gustavobgama
gustavobgama / MySQLDump.sh
Created December 3, 2013 20:17
Commands to export/import/transport mysql database dumps
# Reference: http://webcheatsheet.com/sql/mysql_backup_restore.php
# import without compression
mysql --host=host --user=user --password=password database < path_to_file.sql
# import with compression
gunzip < path_to_file.sql.gz | mysql --host=host --user=user --password=password database
# export wihtout compression
mysqldump --host=host --user=user --password=password database table --where="condition" > path_to_file.sql
@gustavobgama
gustavobgama / AutoIncrement.sql
Created December 18, 2013 19:03
View auto increment value of a table
SELECT `AUTO_INCREMENT`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = SCHEMA()
AND `TABLE_NAME` = 'tbl_name';
@gustavobgama
gustavobgama / GetLastMatch.sh
Created December 23, 2013 17:06
Get last match in file
tac file | grep -m 1 term
@gustavobgama
gustavobgama / TarGzCommands.sh
Created January 15, 2014 15:19
Tar gz commands
# compact
tar -zcvf file.tar.gz source-folder
# extract
tar -zxvf file.tar.gz
@gustavobgama
gustavobgama / SeachForColumn.sql
Created January 17, 2014 09:43
Search for a column in all tables
SELECT table_name,table_schema FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name='column_name';