September 28th, 2009
mysqlslap is worth a look
mysqlslap --host=myhostname --user=myusername -p'mypassword' --create-schema=mydatabase --delimiter=';' --concurrency=10 --iterations=5 --query=/tmp/queriestobenchmark.sql
SAMPLE /tmp/queriestobenchmark.sql file
SELECT * FROM users; SELECT title FROM forum
Tags: benchmark, MySQL
Posted in MySQL | No Comments »
September 28th, 2009
To find and replace “findme” with “replacewithme” in all HTML files in a directory /var/www/html use
find /var/www/html -name '*.html' -print0 |xargs -0 perl -p -i -e 's/findme/replacewithme/g'
To find and replace “findme” with “replacewithme” in all HTML files in a directory /var/www/html and to backup the original files as let’s say filename.unixtimestamp use
find /var/www/html -name '*.html' -print0 |xargs -0 perl -p -i.`date +%s` -e 's/findme/replacewithme/g'
Tags: find and replace, perl
Posted in Unix | No Comments »
September 28th, 2009
Use --color=auto with grep to highlight the matches
cat somefile | grep --color=auto "findme"
Tags: grep
Posted in Unix | No Comments »
September 28th, 2009
To find “findme” (case-insensitive) in all html files in /var/www/html directory use
find /var/www/html -name "*.html" -exec grep -i -l "FiNDmE" {} \;
To find “findme” (case-sensitive) in all html files in /var/www/html directory use
find /var/www/html -name "*.html" -exec grep -l "findme" {} \;
Tags: find text, grep
Posted in Unix | No Comments »
September 20th, 2009
To create a copy of database mysource on Server A as database mydestination on Server B, I follow these two steps:
1) Create database mydestination on Server B.
CREATE database mydestination
2) Then, run this command
mysqldump -hipaddressofserverA -uusernameofserverA -ppasswordofofserverA mysource | mysql -hipaddressofserverB -uusernameofserverB -ppasswordofserverB -C mydestination
Tags: copy database, MySQL
Posted in MySQL | No Comments »
September 20th, 2009
To unblock (open) say port 8000 use:
/sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
Tags: CentOS, unblock port
Posted in CentOS | No Comments »