Skip to content

Instantly share code, notes, and snippets.

Export:

mysqldump -uroot -p [database] [table1] [table2]> [name].sql

Import:

mysql -u... -p... [database] < [name].sql

Query Slow on Mysql

#!/bin/bash
# Save DIR
SAVEDIR=xx
DATE=`date +%Y%m%d`
# xx
DBUSER=xx
DBPASS=xx
DB_NAME=xx
/usr/bin/mysqldump -u $DBUSER -p$DBPASS --skip-lock-tables $DB_NAME | gzip -9 > $SAVEDIR/${DB_NAME}_${DATE}.sql
@khanhkid
khanhkid / GCP_command.md
Last active August 30, 2018 10:58
command work with GCP server

Instance

#push file to a instance

gcloud compute scp [LOCAL_FILE_PATH] [INSTANCE_NAME]:~/

#download file frrm a instance

gcloud compute scp --recurse [INSTANCE_NAME]:[REMOTE_DIR] [LOCAL_DIR]

@khanhkid
khanhkid / When_Server_HighCPU.md
Last active July 2, 2019 04:45
When_Server_HighCPU

MySQL

#show proccess list

watch -n 1 'echo "show processlist;" | mysql -uroot -proot';

#kill a thread id

kill <thread_id>;

CPU, RAM, PROCESS

@khanhkid
khanhkid / linux-command.md
Last active July 26, 2019 02:39
Linux command

Linux Command


Network

#Port open in netstar -tupln

netstat -anp | grep -w 443 | grep ESTABLISHED | wc -l grep -w : count exactly

Check SSLs

@khanhkid
khanhkid / gist:aec8f12155d9401d3b3967446678cf98
Created February 22, 2018 08:04 — forked from wardbekker/gist:964146
Naive parallel import of Compressed MYSQL dump file
# Split MYSQL dump file
zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }'
# Parallel import using GNU Parallel http://www.gnu.org/software/parallel/
ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"
@khanhkid
khanhkid / API.md
Created January 17, 2018 03:54 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@khanhkid
khanhkid / build_mysql.sh
Created March 30, 2017 05:19 — forked from shichao-an/build_mysql.sh
Build and install MySQL 5.1 from source on Ubuntu 14.04
#!/bin/bash
# Run as root
set -e
apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql