Export mysql database based on a where condition

By Tum. | On Monday, December 30th, 2013 - No Comments »
Export mysql database based on a where condition

MYSQLDUMP เป็นโปรแกรมที่เอาไว้ใช้ในการ export data จาก MySQL database ซึ่งโดยการใช้งานทั่วไปแล้วนิยมนำ MYSQLDUMP มาใช้ในการ export ข้อมูลออกมาหมดทั้งหมด (table หรือ database) แต่ถ้าหากต้องการ export ข้อมูลบางส่วนออกมาด้วยการใช้ where ก็สามารถทำได้เช่นกัน โดยให้ใช้ option –where แล้วตามด้วยเงื่อนไขต่างๆ. 

How to read pcap file in Linux CLI using tcpdump

By Tum. | On Tuesday, November 12th, 2013 - No Comments »
How to read pcap file in Linux CLI using tcpdump

ไฟล์ pcap (packet capture) ที่ได้มาจาก tcpdump หรืออุปกรณ์ network อื่นๆ จะเป็น binary file ซึ่งไม่สามารถเปิดอ่านผ่าน text editor เช่น vi, nano หรือโปรแกรมอ่านไฟล์อื่นๆ เช่น less cat ได้ ดังตัวอย่าง  

Installing MySQL 5.6 using the MySQL yum repository

By Tum. | On Monday, November 11th, 2013 - No Comments »
Installing MySQL 5.6 using the MySQL yum repository

Oracle ได้ออก MySQL Yum repository เพื่อช่วยให้สามารถติดตั้งและ update MySQL server ได้สะดวกยิ่งขึ้น โดยในขั้นต้นจะรองรับ Linux distro ดังนี้ Red Hat/Oracle Enterprise Linux/CentOS 6 Fedora 18 และ 19  

[Bug] Invalid of GRANT command will breaks replication

By Tum. | On Wednesday, November 6th, 2013 - No Comments »
[Bug] Invalid of GRANT command will breaks replication

MySQL 5.6 มี bug ที่ควรระวัง คือการรันคำสั่ง GRANT privileges บน PhpMyAdmin อาจทำให้เกิด slave หยุด replicate ข้อมูลได้ (bug report: http://bugs.mysql.com/bug.php?id=68892) หลังจากได้ใช้งาน MySQL 5.6 (version 5.6.14-1) แบบ replication ก็พบปัญหาการใช้งานเมื่อทำการ GRANT สิทธิให้กับ user บน PhpMyAdmin ก็พบว่า slave หยุดการ replicate ข้อมูล และมี error log ดังนี้ Last_SQL_Errno:. 

How to redirect stdout and stderr to log file

By Tum. | On Sunday, November 3rd, 2013 - No Comments »
How to redirect stdout and stderr to log file

วิธีการ redirect standard output และ standard error ไปเก็บไว้ยัง log file การ redirect stdout and stderr ไปยัง log file ที่ถูกต้อง command > /path/to/log 2>&1 123  command > /path/to/log 2>&1  ระบบจะทำการ redirect stdout ไปยัง log file และพร้อมกับ redirect stderr ไปยัง stdout ซึ่งส่งผลให้ทั้ง stdout และ stderr ถูก redirect เข้า log file  

How to compress mysqldump output with gzip/bzip2

By Tum. | On Sunday, November 3rd, 2013 - No Comments »
How to compress mysqldump output with gzip/bzip2

mysqldump คือคำสั่งที่ใช้ในการ export ข้อมูลใน MySQL ออกมาในรูปแบบของ sql format ซึ่งนิยมนำมาใช้ในการ backup ข้อมูลบน MySQL โดยทั่วไปแล้วเวลา backup database ด้วย mysqldump จะไม่มีการ compress ข้อมูลดังนั้นถ้าหากข้อมูลมีขนาดใหญ่จะทำให้ไฟล์ที่ได้จาก mysqldump มีขนาดใหญ่ตาม ดังนั้นในบทความนี้จะนำเสนอวิธีการ. 

Find top frequently using queries on MySQL

By Tum. | On Tuesday, October 22nd, 2013 - No Comments »
Find top frequently using queries on MySQL

MySQL tip: การหา top 10 query บน MYSQL ที่ถูกใช้งานมากที่สุดในช่วงเวลาหนึ่งๆ โดยการหา top 10 query นี้สามารถทำได้ 2 วิธีด้วยกัน คือ ใช้ tcpdump หรือ mysqlbinlog ในการนำ query ต่างๆ มาเข้า process การจัดลำดับ หา top 10 query ด้วย tcpdump