Wednesday, March 6, 2013

How can I determine the differences between two MySQL databases?

mysqldump --skip-comments --no-data -u your_user1 -p your_database_name1 > file_1.sql
mysqldump --skip-comments --no-data -u your_user2 -p your_database_name2 > file_2.sql
diff file_1.sql file_2.sql
Note that the first two lines may end up being identical except for the .sql file name at the end of the command (because databases that you want to compare often exist in independent environments). For example, you might run the first command locally and the second on a remote dev machine. In both instances your user may be root and your database name might be the name of your project. If you run the first command on your local machine and the second on a remote, you'll have to scp file_2.sql to your local machine before running the diff command. Enjoy!

Monday, March 4, 2013

How do I search multiple files for a specific word in one fell swoop?

# To list files that contain "the phrase"
grep 'the phrase' -li -r /etc
# To search for "the phrase" within a specific file
grep 'the phrase' /etc/httpd/conf/httpd.conf
This command is particularily useful if you're searching a folder full of MS Word docs. Word docs aren't plain text files (duh) and therefore don't get matched properly by most application level search features (e.g. TextWrangler).

The 'l' option is shorthand for '--files-with-matches'. Only the names of files containing selected lines are written to standard output.

The 'i' option is shorthand for '--ignore-case'. Omit this option if you do want your search to be case sensitive.

Lastly, the 'r' option is shorthand for '--recursive'. This tells grep to recursively search the subdirectories listed. This is key when you're interested in searching a folder full of docs (as opposed to an individual file).

Friday, February 15, 2013

How do I setup my new Debian 6.0 (squeeze) server?

Great question, Chad Keck has a great answer: http://www.youtube.com/watch?v=JZepJ2Vx5-U&list=HL1327264781&feature=mh_lolz Also, here's the direct link to the iptables.txt Chad refers to in the video: http://articles.slicehost.com/assets/2007/9/4/iptables.txt

How do I install phpMyAdmin on my new server?

Great question, HowToForge has a great answer: http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-debian-squeeze-lamp-p2 followed up by:
# Open Apache's conf file:
sudo nano /etc/apache2/httpd.conf

# Add this line:
Include /etc/phpmyadmin/apache.conf

# Then, run:
sudo /etc/init.d/apache2 restart

# And now phpMyAdmin should work! Check it out at http://yourip/phpmyadmin/.

How do I install MySQL & PHP on my new server?

Great question, the Linode Library has a great answer: http://library.linode.com/lamp-guides/debian-6-squeeze

Why is MAMP PRO so slow?

Not sure. But I can tell you how to fix it.

Run the following series of commands:
# Where yoursite.local is the name of your site
sudo echo '::1 yoursite.local' > /tmp/newfile
sudo cat /etc/hosts >> /tmp/newfile
sudo mv /tmp/newfile /etc/hosts
Problem solved! Check it out for yourself at yoursite.local right now.

Cheers!

About Me

My photo
I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.