<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edvanta&#039;s KnowledgeBase</title>
	<atom:link href="http://edvanta.com/knowledgebase/feed/" rel="self" type="application/rss+xml" />
	<link>http://edvanta.com/knowledgebase</link>
	<description>Journaling the journey...</description>
	<lastBuildDate>Thu, 23 Sep 2010 19:41:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache virtual hosts</title>
		<link>http://edvanta.com/knowledgebase/2010/09/24/apache-virtual-hosts/</link>
		<comments>http://edvanta.com/knowledgebase/2010/09/24/apache-virtual-hosts/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 19:36:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[virtual host]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=172</guid>
		<description><![CDATA[Good post Vikram!! To add to it, a single computer using apache web server can serve as multiple websites as if they are on separate hosts using the same concept. There are two ways to do it.
1. Creating a name-based virtual host
2. Creating an ip based virtual host
What you just created was a namebased virtual [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Good post Vikram!! To add to it, a single computer using apache web server can serve as multiple websites as if they are on separate hosts using the same concept. There are two ways to do it.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1. Creating a name-based virtual host</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2. Creating an ip based virtual host</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">What you just created was a namebased virtual host. incase of an ip based virtual you skip the ServerName.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">For hosting multiple sites using ip addresses.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">NameVirtualHost *</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost *&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@vikramsolia.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/vikram/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost XXX.XXX.XXX.102&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@navindutta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/nave/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost XXX.XXX.XXX.103&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@jaigupta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/jai/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">For multiple web domains on the same computer</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">NameVirtualHost *</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost *&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerName www.vikramsolia.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAlias vikramsolia.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@vikramsolia.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/vikram/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost XXX.XXX.XXX.102&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerName www.navindutta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAlias navindutta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@navindutta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/nave/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;VirtualHost XXX.XXX.XXX.103&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerName www.jaigupta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAlias jaigupta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ServerAdmin mail@jaigupta.com</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">DocumentRoot /home/jai/public_html</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/VirtualHost&gt;</div>
<p>A single computer using apache web server can serve as multiple websites as if they are on separate hosts using the same concept. There are two ways to do it.</p>
<p>1. Creating an ip-based virtual host</p>
<p>2. Creating a name-based virtual host</p>
<p><strong>For hosting multiple sites using ip addresses.</strong></p>
<p><em>NameVirtualHost *</em></p>
<p><em> </em></p>
<p><em>&lt;VirtualHost *&gt;</em></p>
<p><em>ServerAdmin mail@navindutta.com</em></p>
<p><em>DocumentRoot /home/navindutta/public_html</em></p>
<p><em>&lt;/VirtualHost&gt;</em></p>
<p><em> </em></p>
<p><em>&lt;VirtualHost XXX.XXX.XXX.102&gt;</em></p>
<p><em>ServerAdmin mail@navin.com</em></p>
<p><em>DocumentRoot /home/navin/public_html</em></p>
<p><em>&lt;/VirtualHost&gt;</em></p>
<p><em> </em></p>
<p><em>&lt;VirtualHost XXX.XXX.XXX.103&gt;</em></p>
<p><em>ServerAdmin mail@nave.com</em></p>
<p><em>DocumentRoot /home/nave/public_html</em></p>
<p><em><span style="font-style: normal;"><em>&lt;/VirtualHost&gt;</em></span></em></p>
<p><em> </em></p>
<p><strong>For multiple web domains on the same computer</strong></p>
<p><em>NameVirtualHost *</em></p>
<p><em>&lt;VirtualHost *&gt;</em></p>
<p><em>ServerName www.navindutta.com</em></p>
<p><em>ServerAlias navindutta.com</em></p>
<p><em>ServerAdmin mail@navindutta.com</em></p>
<p><em>DocumentRoot /home/navindutta/public_html</em></p>
<p><em>&lt;/VirtualHost&gt;</em></p>
<p><em> </em></p>
<p><em>&lt;VirtualHost XXX.XXX.XXX.102&gt;</em></p>
<p><em>ServerName www.navin.com</em></p>
<p><em>ServerAlias navin.com</em></p>
<p><em>ServerAdmin mail@navin.com</em></p>
<p><em>DocumentRoot /home/navin/public_html</em></p>
<p><em>&lt;/VirtualHost&gt;</em></p>
<p><em> </em></p>
<p><em>&lt;VirtualHost XXX.XXX.XXX.103&gt;</em></p>
<p><em>ServerName www.nave.com</em></p>
<p><em>ServerAlias nave.com</em></p>
<p><em>ServerAdmin mail@nave.com</em></p>
<p><em>DocumentRoot /home/nave/public_html</em></p>
<p><em>&lt;/VirtualHost&gt;</em></p>
<p><em> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/09/24/apache-virtual-hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moodle mod rewrite</title>
		<link>http://edvanta.com/knowledgebase/2010/05/23/moodle-mod-rewrite/</link>
		<comments>http://edvanta.com/knowledgebase/2010/05/23/moodle-mod-rewrite/#comments</comments>
		<pubDate>Sun, 23 May 2010 12:56:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=167</guid>
		<description><![CDATA[# Turn on rewrites.
RewriteEngine on
# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Only apply to URLs that aren&#8217;t already under folder.
RewriteCond %{REQUEST_URI} !^/moodledir/
# Don&#8217;t apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /moodledir/$1
# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule [...]]]></description>
			<content:encoded><![CDATA[<p># Turn on rewrites.<br />
RewriteEngine on</p>
<p># Only apply to URLs on this domain<br />
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$</p>
<p># Only apply to URLs that aren&#8217;t already under folder.<br />
RewriteCond %{REQUEST_URI} !^/moodledir/</p>
<p># Don&#8217;t apply to URLs that go to existing files or folders.<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d</p>
<p># Rewrite all those to insert /folder.<br />
RewriteRule ^(.*)$ /moodledir/$1</p>
<p># Also redirect the root folder.<br />
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$<br />
RewriteRule ^(/)?$ moodledir/index.php [L]</p>
<p>Please note that this would work for all file url requests like view.php or index.php but not file.php requests. Another rule needs to be written for that.</p>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/05/23/moodle-mod-rewrite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Moodle migration in 3 steps</title>
		<link>http://edvanta.com/knowledgebase/2010/05/23/moodle-migration-in-3-steps/</link>
		<comments>http://edvanta.com/knowledgebase/2010/05/23/moodle-migration-in-3-steps/#comments</comments>
		<pubDate>Sat, 22 May 2010 19:24:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=163</guid>
		<description><![CDATA[1. Copy all files from the root of your Moodle installation and the moodle data directory.
#rsync -av -e ssh sourse/ username@newserver.com:/path/to/destination/
2. Dump your Moodle database and import it it new server
#mysqldump &#8211;allow-keywords &#8211;opt -uMySQL_USERNAME -pPASSWORD DATABASE &#124; ssh username@newserver.com &#8220;mysql -uMySQL_USERNAME -pPASSWORD DATABASE&#8221;
3. Edit config.php to update all database access details, file paths and web [...]]]></description>
			<content:encoded><![CDATA[<p>1. Copy all files from the root of your Moodle installation and the moodle data directory.</p>
<p>#rsync -av -e ssh sourse/ username@newserver.com:/path/to/destination/</p>
<p>2. Dump your Moodle database and import it it new server</p>
<p>#mysqldump &#8211;allow-keywords &#8211;opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh username@newserver.com &#8220;mysql -uMySQL_USERNAME -pPASSWORD DATABASE&#8221;</p>
<p>3. Edit config.php to update all database access details, file paths and web location</p>
<p>Finally test everything and fix any link errors using http://newserver.com/moodle/admin/replace.php Thats all <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/05/23/moodle-migration-in-3-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>htaccess cheatsheet</title>
		<link>http://edvanta.com/knowledgebase/2010/05/12/htaccess-cheatsheet/</link>
		<comments>http://edvanta.com/knowledgebase/2010/05/12/htaccess-cheatsheet/#comments</comments>
		<pubDate>Wed, 12 May 2010 17:21:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=159</guid>
		<description><![CDATA[Enable Directory Browsing
Options +Indexes
## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

Disable Directory Browsing
Options All -Indexes

Customize Error Messages
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html

Get SSI working with HTML/SHTML
AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm

Change Default Page (order is followed!)
DirectoryIndex myhome.htm index.htm index.php

Block Users from accessing the site
&#60;limit GET [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Enable Directory Browsing</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">Options +Indexes
## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Disable Directory Browsing</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">Options All -Indexes
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Customize Error Messages</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Get <span style="padding: 0px; margin: 0px;">SSI</span> working with HTML/SHTML</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Change Default Page (order is followed!)</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">DirectoryIndex myhome.htm index.htm index.php
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Block Users from accessing the site</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">&lt;limit GET POST PUT&gt;
order deny,allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .spammers.com
allow from all
&lt;/limit&gt;
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Allow only <span style="padding: 0px; margin: 0px;">LAN</span> users</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">order deny,allow
deny from all
allow from 192.168.0.0/24
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Redirect Visitors to New Page/Directory</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">Redirect oldpage.html http://www.domainname.com/newpage.html
Redirect /olddir http://www.domainname.com/newdir/
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Block site from specific referrers</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
RewriteRule .* - [F]
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Block Hot Linking/Bandwidth hogging</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Want to show a “Stealing is Bad” message too?</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">Add this below the <em>Hot Link Blocking</em> code:</p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Stop .htaccess (or any other file) from being viewed</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">&lt;files file-name&gt;
order allow,deny
deny from all
&lt;/files&gt;
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Avoid the 500 Error</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;"># Avoid 500 error by passing charset
AddDefaultCharset utf-8
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Grant <span style="padding: 0px; margin: 0px;">CGI</span> Access in a directory</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">Options +ExecCGI
AddHandler cgi-script cgi pl
# To enable all scripts in a directory use the following
# SetHandler cgi-script
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Password Protecting Directories</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">Use the <a style="color: #5371c5; text-decoration: none; padding: 0px; margin: 0px;" href="http://thejackol.com/scripts/htpasswdgen.php">.htaccess Password Generator</a> and follow the brief instructions!</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Change Script Extensions</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">AddType application/x-httpd-php .gne
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><code style="padding: 0px; margin: 0px;">gne</code> will now be treated as <span style="padding: 0px; margin: 0px;">PHP</span> files! Similarly, <code style="padding: 0px; margin: 0px;">x-httpd-cgi</code> for <span style="padding: 0px; margin: 0px;">CGI</span> files, etc.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Use MD5 Digests</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">Performance may take a hit but if thats not a problem, this is a nice option to turn on.</p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">ContentDigest On
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>The CheckSpelling Directive</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add <code style="padding: 0px; margin: 0px;">CheckSpelling On</code> to your htaccess file.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>The ContentDigest Directive</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">As the Apache core features documentation says: “This directive enables the generation of Content-MD5 headers as defined in <a style="color: #5371c5; text-decoration: none; padding: 0px; margin: 0px;" href="http://www.ietf.org/rfc/rfc1864.txt">RFC1864</a> respectively <a style="color: #5371c5; text-decoration: none; padding: 0px; margin: 0px;" href="http://www.ietf.org/rfc/rfc2068.txt">RFC2068</a>. The Content-MD5 header provides an end-to-end message integrity check (<span style="padding: 0px; margin: 0px;">MIC</span>) of the entity-body. A proxy or client may check this header for detecting accidental modification of the entity-body in transit.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached). Content-MD5 is only sent for documents served by the core, and not by any module. For example, <span style="padding: 0px; margin: 0px;">SSI</span> documents, output from <span style="padding: 0px; margin: 0px;">CGI</span> scripts, and byte range responses do not have this header.”</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;">To turn this on, just add <code style="padding: 0px; margin: 0px;">ContentDigest On</code>.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Enable Gzip – Save Bandwidth</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;"># BEGIN GZIP
&lt;ifmodule mod_deflate.c&gt;
# Combine the below two lines - I've split it up for presentation
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css
  application/x-javascript application/javascript
&lt;/ifmodule&gt;
# END GZIP
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Turn off <code style="padding: 0px; margin: 0px;">magic_quotes_gpc</code></strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;"># Only if you use PHP
&lt;ifmodule mod_php4.c&gt;
php_flag magic_quotes_gpc off
&lt;/ifmodule&gt;
</code></pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;"><strong>Set an Expires header and enable Cache-Control</strong></p>
<pre style="padding: 0px; margin: 0px;"><code style="padding: 0px; margin: 0px;">&lt;ifmodule mod_expires.c&gt;
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 7200 seconds"
  ExpiresByType image/gif "access plus 518400 seconds"
  ExpiresByType image/jpeg "access plus 518400 seconds"
  ExpiresByType image/png "access plus 518400 seconds"
  ExpiresByType text/css "access plus 518400 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
&lt;/ifmodule&gt;
</code>
<code style="padding: 0px; margin: 0px;">&lt;ifmodule mod_headers.c&gt;
  # Cache specified files for 6 days
  &lt;filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"&gt;
  Header set Cache-Control "max-age=518400, public"
  &lt;/filesmatch&gt;
  # Cache HTML files for a couple hours
  &lt;filesmatch "\.(html|htm)$"&gt;
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  &lt;/filesmatch&gt;
  # Cache PDFs for a day
  &lt;filesmatch "\.(pdf)$"&gt;
  Header set Cache-Control "max-age=86400, public"
  &lt;/filesmatch&gt;
  # Cache Javascripts for 2.5 days
  &lt;filesmatch "\.(js)$"&gt;
  Header set Cache-Control "max-age=216000, private"
  &lt;/filesmatch&gt;
&lt;/ifmodule&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/05/12/htaccess-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sshfs and remote php debugging</title>
		<link>http://edvanta.com/knowledgebase/2010/05/12/sshfs-and-remote-php-debugging/</link>
		<comments>http://edvanta.com/knowledgebase/2010/05/12/sshfs-and-remote-php-debugging/#comments</comments>
		<pubDate>Tue, 11 May 2010 20:10:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=154</guid>
		<description><![CDATA[Sshfs is used for viewing and exploring remote file system as if it was your local machine. It is pretty simple to setup
#yum install sshfs fuse-sshfs
Once you have installed sshfs we can use it to connect to any server which allows ssh access
#mkdir /mnt/moodle_server
#sshfs user@server.com:/home/abcd/public_html/moodle /mnt/moodle_server/
Enter password and you re done.
Now lets say we want [...]]]></description>
			<content:encoded><![CDATA[<p>Sshfs is used for viewing and exploring remote file system as if it was your local machine. It is pretty simple to setup</p>
<p>#yum install sshfs fuse-sshfs</p>
<p>Once you have installed sshfs we can use it to connect to any server which allows ssh access</p>
<p>#mkdir /mnt/moodle_server</p>
<p>#sshfs user@server.com:/home/abcd/public_html/moodle /mnt/moodle_server/</p>
<p>Enter password and you re done.</p>
<p>Now lets say we want to debug this system locally so we will mount our system in the /var/www/html so that our apache can read it</p>
<p>#sshfs user@server.com:/home/abcd/public_html/moodle /var/www/html/moodle_server</p>
<div>
<p>I got permission denied forbidden errot. To resolve this I have it the necessary permission</p>
<p>#sshfs -o allow_other,uid=500;gid=500 user@server.com:/home/abcd/public_html/moodle /var/www/html/moodle_server</p>
<p>Bingo It lets me get in. Now only one thing remains. I need to setup the mysql user and password same as on the server locally. <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Ka Ching!!! <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  There you go <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  debugging your remote file system php files right from your desktop. No upload download permision abcd stuff <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>If you want to auto mount the system when you access it. install a key pair using ssh-keygen. or use autofs for automounting</p>
<p><span style="font-family: Verdana, Arial, Tahoma; line-height: normal; font-size: 12px;">Want to be able to use the local rights system on that folder? (just if you dont want to go on but want to be able to mount a remote filesystem and have the<br />
local rights translated to it.)<br />
</span></p>
<p><span style="font-family: Verdana, Arial, Tahoma; line-height: normal; font-size: 12px;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;">For default permissions</p>
<p>#sshfs -o allow_other, default_permissions user@server.com:/home/abcd/public_html/moodle /var/www/html/moodle_server</p>
<div></div>
<p></span>As i want the remote directory mount automaticly (with autofs described later on)<br />
<strong>i need a passwordless ssh login. This can be done with help of generating public keys. </strong><br />
A public key for the local system is generated with the command:</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">ssh-keygen -t rsa</pre>
</div>
<p>(hit enter so its saved in your home directory under .ssh/id_rsa</p>
<p>(hit enter for no passphrase)</p>
<p>you have now a .ssh directory with two files<br />
id_rsa and id_rsa.pub</p>
<p>id_rsa is your private key ! protect it well let only YOU have rights on it (default) as if this gets compromised<br />
anyone can gain access to your remote host</p>
<p>id_rsa.pub is the public key it is readable by others and this is what you have to send to the remote host so it can have it in its authorized_keys file</p>
<p>Copy now the public key to the remote machine</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">scp ~/.ssh/id_rsa.pub user@server.com:~/.</pre>
</div>
<p>logon with an ssh client to the remote machine the id_rsa.pub file content must be added to the authorized_keys file in the .ssh directory of the homedir of the user you want to connect as.</p>
<p>In this example the remote users home directory</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 50px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">ssh user@server.com
cat ~/id_*.pub &gt;&gt; ~/.ssh/authorized_keys</pre>
</div>
<p>A alternative simpler way to get your public key in the authorized_keys file of your remote host is with ssh-copy-id<br />
from your local machine type</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr"> ssh-copy-id -i ~/.ssh/id_rsa.pub user@server.com</pre>
</div>
<p>this does the whole process of copying your public key to the remote machnes users homedir in .ssh in authorized_keys<br />
and sets the rights oke</p>
<p>As later on the mount is done by the local root user you need the public key of root too.</p>
<p>so give command</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">sudo gnome-terminal</pre>
</div>
<p>to open a command terminal as user root and repeat the above procedure.</p>
<p>after this the file authorized_keys at the remote station has both the public key of the local user and the local root so it works in test and in production later when root does the mounwork&#8230;.</p>
<p>Set the right rights for the file authorized_keys or the ssh deamon ( in my case dropbear) might not want to process the authorize_keys file</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 50px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">ssh remoteuser@remote.machine.address
chmod 0600 ~/.ssh/authorized_keys</pre>
</div>
<p>logout from the remote machine and test.</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">ssh user@server.com</pre>
</div>
<p>You should now be able to login without giving a password.</p>
<p>If it does not work debug with ssh -v option .</p>
<p>(same for the sudo gnome-terminal )</p>
<p>If it works you can see if the mount works passwordless too</p>
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;">
<div class="smallfont" style="color: #000000; margin-top: 2px; margin-bottom: 2px;">Code:</div>
<pre class="alt2" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; color: #000000; width: 640px; height: 34px; text-align: left; overflow-x: auto; overflow-y: auto; background-position: initial initial; background-repeat: initial initial; padding: 6px; margin: 0px; border: 1px inset initial;" dir="ltr">sudo sshfs user@server:/Directory/to/mount /var/www/html/moodle_server</pre>
</div>
<p>So ! thats done!!! you can now mount the remote filesystem without using a password.</span></p>
<p>Cheers!! <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">
<p>sshfs -o allow_other,uid=500,gid=500</p>
<p>academy@uspja.com:/home/academy/public_html /var/www/html/uspja_academy_server/</p></div>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/05/12/sshfs-and-remote-php-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulling data from cross-domain URL using jQuery and YQL</title>
		<link>http://edvanta.com/knowledgebase/2010/05/12/pulling-data-from-cross-domain-url-using-jquery-and-yql/</link>
		<comments>http://edvanta.com/knowledgebase/2010/05/12/pulling-data-from-cross-domain-url-using-jquery-and-yql/#comments</comments>
		<pubDate>Tue, 11 May 2010 19:57:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=151</guid>
		<description><![CDATA[As a security check. $.load and $.get are not allowed to make cross-domain requests to pull and include files/data, which means that residing sitea.com you can&#8217;t pull file/data from siteb.com. DOM doesn&#8217;t allow it. However using YQL its a piece of cake   Here is how.
&#60;div id=&#8221;containerdiv1&#8243;&#62;&#60;/div&#62;
&#60;script src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&#8221; type=&#8221;text/javascript&#8221; charset=&#8221;utf-8&#8243;&#62;&#60;/script&#62; 
&#60;script type&#62;
// Accepts a [...]]]></description>
			<content:encoded><![CDATA[<p>As a security check. $.load and $.get are not allowed to make cross-domain requests to pull and include files/data, which means that residing sitea.com you can&#8217;t pull file/data from siteb.com. DOM doesn&#8217;t allow it. However using YQL its a piece of cake <img src='http://edvanta.com/knowledgebase/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Here is how.</p>
<p>&lt;div id=&#8221;containerdiv1&#8243;&gt;&lt;/div&gt;</p>
<p>&lt;script src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&#8221; type=&#8221;text/javascript&#8221; charset=&#8221;utf-8&#8243;&gt;&lt;/script&gt;<span style="white-space: pre;"> </span></p>
<p>&lt;script type&gt;</p>
<p>// Accepts a url and a callback function to run.</p>
<p>function requestCrossDomain( site, callback ) {</p>
<p><span style="white-space: pre;"> </span>/*</p>
<p><span style="white-space: pre;"> </span>// If no url was passed, exit.</p>
<p><span style="white-space: pre;"> </span>if ( !site ) {</p>
<p><span style="white-space: pre;"> </span>alert(&#8217;No site was passed.&#8217;);</p>
<p><span style="white-space: pre;"> </span>return false;</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>*/</p>
<p><span style="white-space: pre;"> </span>// Take the provided url, and add it to a YQL query. Make sure you encode it!</p>
<p><span style="white-space: pre;"> </span>var yql = &#8216;http://query.yahooapis.com/v1/public/yql?q=&#8217; + encodeURIComponent(&#8217;select * from html where url=&#8221;&#8216; + site + &#8216;&#8221;&#8216;) + &#8216;&amp;format=xml&amp;callback=?&#8217;;</p>
<p><span style="white-space: pre;"> </span>// Request that YSQL string, and run a callback function.</p>
<p><span style="white-space: pre;"> </span>// Pass a defined function to prevent cache-busting.</p>
<p><span style="white-space: pre;"> </span>$.getJSON( yql, cbFunc );</p>
<p><span style="white-space: pre;"> </span>function cbFunc(data) {</p>
<p><span style="white-space: pre;"> </span>// If we have something to work with&#8230;</p>
<p><span style="white-space: pre;"> </span>if ( data.results[0] ) {</p>
<p><span style="white-space: pre;"> </span>// Strip out all script tags, for security reasons.</p>
<p><span style="white-space: pre;"> </span>// BE VERY CAREFUL. This helps, but we should do more.</p>
<p><span style="white-space: pre;"> </span>data = data.results[0].replace(/&lt;script[^&gt;]*&gt;[\s\S]*?&lt;\/script&gt;/gi, &#8221;);</p>
<p><span style="white-space: pre;"> </span>// If the user passed a callback, and it</p>
<p><span style="white-space: pre;"> </span>// is a function, call it, and send through the data var.</p>
<p><span style="white-space: pre;"> </span>if ( typeof callback === &#8216;function&#8217;) {</p>
<p><span style="white-space: pre;"> </span>callback(data);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>// Else, Maybe we requested a site that doesn&#8217;t exist, and nothing returned.</p>
<p><span style="white-space: pre;"> </span>else throw new Error(&#8217;Nothing returned from getJSON.&#8217;);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<p>&lt;/script&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p>$(document).ready(function() {</p>
<p><span style="white-space: pre;"> </span>var path = &#8220;http://navindutta.com/&#8221;;</p>
<p><span style="white-space: pre;"> </span>requestCrossDomain(path, function(results) {</p>
<p><span style="white-space: pre;"> </span>$(&#8217;#containerdiv1&#8242;).html(results);</p>
<p><span style="white-space: pre;"> </span>});</p>
<p><span style="white-space: pre;"> </span>return false;</p>
<p>});<span style="white-space: pre;"> </span></p>
<p>&lt;/script&gt;</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;div id=&#8221;container&#8221;&gt;&lt;/div&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;script src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&#8221; type=&#8221;text/javascript&#8221; charset=&#8221;utf-8&#8243;&gt;&lt;/script&gt;<span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;script type=&#8221;text/javascript&#8221; src=&#8221;http://academy.uspja.com/lms/customblock/js/cross-domain-requests.js&#8221;&gt;&lt;/script&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;script type=&#8221;text/javascript&#8221;&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$(document).ready(function() {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>var path = &#8220;http://a.uspja.com/personalmenu/&#8221;;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>requestCrossDomain(path, function(results) {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$(&#8217;#container&#8217;).html(results);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>});</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">});<span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/script&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/05/12/pulling-data-from-cross-domain-url-using-jquery-and-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL statements &amp; clauses</title>
		<link>http://edvanta.com/knowledgebase/2010/04/27/mysql-statements-clauses/</link>
		<comments>http://edvanta.com/knowledgebase/2010/04/27/mysql-statements-clauses/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 08:10:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=139</guid>
		<description><![CDATA[MYSQL Statements and clauses
ALTER DATABASE

ALTER TABLE

ALTER VIEW

ANALYZE TABLE

BACKUP TABLE

CACHE INDEX

CHANGE MASTER TO

CHECK TABLE

CHECKSUM TABLE

COMMIT

CREATE DATABASE

CREATE INDEX

CREATE TABLE

CREATE VIEW

DELETE

DESCRIBE

DO

DROP DATABASE

DROP INDEX

DROP TABLE

DROP USER

DROP VIEW

EXPLAIN

FLUSH

GRANT

HANDLER

INSERT

JOIN

KILL

LOAD DATA FROM MASTER

LOAD DATA INFILE

LOAD INDEX INTO CACHE

LOAD TABLE...FROM MASTER

LOCK TABLES

OPTIMIZE TABLE

PURGE MASTER LOGS

RENAME TABLE

REPAIR TABLE

REPLACE

RESET

RESET MASTER

RESET SLAVE

RESTORE TABLE

REVOKE

ROLLBACK

ROLLBACK TO SAVEPOINT

SAVEPOINT

SELECT

SET

SET PASSWORD

SET SQL_LOG_BIN

SET TRANSACTION

SHOW BINLOG EVENTS

SHOW CHARACTER SET

SHOW COLLATION

SHOW COLUMNS

SHOW CREATE DATABASE

SHOW [...]]]></description>
			<content:encoded><![CDATA[<p><strong>MYSQL Statements and clauses</strong></p>
<pre>ALTER DATABASE

ALTER TABLE

ALTER VIEW

ANALYZE TABLE

BACKUP TABLE

CACHE INDEX

CHANGE MASTER TO

CHECK TABLE

CHECKSUM TABLE

COMMIT

CREATE DATABASE

CREATE INDEX

CREATE TABLE

CREATE VIEW

DELETE

DESCRIBE

DO

DROP DATABASE

DROP INDEX

DROP TABLE

DROP USER

DROP VIEW

EXPLAIN

FLUSH

GRANT

HANDLER

INSERT

JOIN

KILL

LOAD DATA FROM MASTER

LOAD DATA INFILE

LOAD INDEX INTO CACHE

LOAD TABLE...FROM MASTER

LOCK TABLES

OPTIMIZE TABLE

PURGE MASTER LOGS

RENAME TABLE

REPAIR TABLE

REPLACE

RESET

RESET MASTER

RESET SLAVE

RESTORE TABLE

REVOKE

ROLLBACK

ROLLBACK TO SAVEPOINT

SAVEPOINT

SELECT

SET

SET PASSWORD

SET SQL_LOG_BIN

SET TRANSACTION

SHOW BINLOG EVENTS

SHOW CHARACTER SET

SHOW COLLATION

SHOW COLUMNS

SHOW CREATE DATABASE

SHOW CREATE TABLE

SHOW CREATE VIEW

SHOW DATABASES

SHOW ENGINES

SHOW ERRORS

SHOW GRANTS

SHOW INDEX

SHOW INNODB STATUS

SHOW LOGS

SHOW MASTER LOGS

SHOW MASTER STATUS

SHOW PRIVILEGES

SHOW PROCESSLIST

SHOW SLAVE HOSTS

SHOW SLAVE STATUS

SHOW STATUS

SHOW TABLE STATUS

SHOW TABLES

SHOW VARIABLES

SHOW WARNINGS

START SLAVE

START TRANSACTION

STOP SLAVE

TRUNCATE TABLE

UNION

UNLOCK TABLES

USE</pre>
<p><strong>String Functions</strong></p>
<pre>AES_DECRYPT

AES_ENCRYPT

ASCII

BIN

BINARY

BIT_LENGTH

CHAR

CHAR_LENGTH

CHARACTER_LENGTH

COMPRESS

CONCAT

CONCAT_WS

CONV

DECODE

DES_DECRYPT

DES_ENCRYPT

ELT

ENCODE

ENCRYPT

EXPORT_SET

FIELD

FIND_IN_SET

HEX

INET_ATON

INET_NTOA

INSERT

INSTR

LCASE

LEFT

LENGTH

LOAD_FILE

LOCATE

LOWER

LPAD

LTRIM

MAKE_SET

MATCH    AGAINST

MD5

MID

OCT

OCTET_LENGTH

OLD_PASSWORD

ORD

PASSWORD

POSITION

QUOTE

REPEAT

REPLACE

REVERSE

RIGHT

RPAD

RTRIM

SHA

SHA1

SOUNDEX

SPACE

STRCMP

SUBSTRING

SUBSTRING_INDEX

TRIM

UCASE

UNCOMPRESS

UNCOMPRESSED_LENGTH

UNHEX

UPPER</pre>
<p><strong>Date and Time Functions</strong></p>
<pre>ADDDATE

ADDTIME

CONVERT_TZ

CURDATE

CURRENT_DATE

CURRENT_TIME

CURRENT_TIMESTAMP

CURTIME

DATE

DATE_ADD

DATE_FORMAT

DATE_SUB

DATEDIFF

DAY

DAYNAME

DAYOFMONTH

DAYOFWEEK

DAYOFYEAR

EXTRACT

FROM_DAYS

FROM_UNIXTIME

GET_FORMAT

HOUR

LAST_DAY

LOCALTIME

LOCALTIMESTAMP

MAKEDATE

MAKETIME

MICROSECOND

MINUTE

MONTH

MONTHNAME

NOW

PERIOD_ADD

PERIOD_DIFF

QUARTER

SEC_TO_TIME

SECOND

STR_TO_DATE

SUBDATE

SUBTIME

SYSDATE

TIME

TIMEDIFF

TIMESTAMP

TIMESTAMPDIFF

TIMESTAMPADD

TIME_FORMAT

TIME_TO_SEC

TO_DAYS

UNIX_TIMESTAMP

UTC_DATE

UTC_TIME

UTC_TIMESTAMP

WEEK

WEEKDAY

WEEKOFYEAR

YEAR

YEARWEEK</pre>
<p><strong>Mathematical and Aggregate Functions</strong></p>
<pre>ABS

ACOS

ASIN

ATAN

ATAN2

AVG

BIT_AND

BIT_OR

BIT_XOR

CEIL

CEILING

COS

COT

COUNT

CRC32

DEGREES

EXP

FLOOR

FORMAT

GREATEST

GROUP_CONCAT

LEAST

LN

LOG

LOG2

LOG10

MAX

MIN

MOD

PI

POW

POWER

RADIANS

RAND

ROUND

SIGN

SIN

SQRT

STD

STDDEV

SUM

TAN

TRUNCATE

VARIANCE</pre>
<p><strong>Flow Control Functions</strong></p>
<pre>CASE

IF

IFNULL

NULLIF</pre>
<p><strong>Command-Line Utilities</strong></p>
<pre>comp_err

isamchk

make_binary_distribution

msql2mysql

my_print_defaults

myisamchk

myisamlog

myisampack

mysqlaccess

mysqladmin

mysqlbinlog

mysqlbug

mysqlcheck

mysqldump

mysqldumpslow

mysqlhotcopy

mysqlimport

mysqlshow

perror</pre>
<p><strong>Perl API &#8211; using functions and methods built into the Perl DBI with MySQL</strong></p>
<pre>available_drivers

begin_work

bind_col

bind_columns

bind_param

bind_param_array

bind_param_inout

can

clone

column_info

commit

connect

connect_cached

data_sources

disconnect

do

dump_results

err

errstr

execute

execute_array

execute_for_fetch

fetch

fetchall_arrayref

fetchall_hashref

fetchrow_array

fetchrow_arrayref

fetchrow_hashref

finish

foreign_key_info

func

get_info

installed_versions

last_insert_id

looks_like_number

neat

neat_list

parse_dsn

parse_trace_flag

parse_trace_flags

ping

prepare

prepare_cached

primary_key

primary_key_info

quote

quote_identifier

rollback

rows

selectall_arrayref

selectall_hashref

selectcol_arrayref

selectrow_array

selectrow_arrayref

selectrow_hashref

set_err

state

table_info

table_info_all

tables

trace

trace_msg

type_info

type_info_all

Attributes for Handles</pre>
<p><strong>PHP API &#8211; using functions built into PHP with MySQL</strong></p>
<pre>mysql_affected_rows

mysql_change_user

mysql_client_encoding

mysql_close

mysql_connect

mysql_create_db

mysql_data_seek

mysql_db_name

mysql_db_query

mysql_drop_db

mysql_errno

mysql_error

mysql_escape_string

mysql_fetch_array

mysql_fetch_assoc

mysql_fetch_field

mysql_fetch_lengths

mysql_fetch_object

mysql_fetch_row

mysql_field_flags

mysql_field_len

mysql_field_name

mysql_field_seek

mysql_field_table

mysql_field_type

mysql_free_result

mysql_get_client_info

mysql_get_host_info

mysql_get_proto_info

mysql_get_server_info

mysql_info

mysql_insert_id

mysql_list_dbs

mysql_list_fields

mysql_list_processes

mysql_list_tables

mysql_num_fields

mysql_num_rows

mysql_pconnect

mysql_ping

mysql_query

mysql_real_escape_string

mysql_result

mysql_select_db

mysql_stat

mysql_tablename

mysql_thread_id

mysql_unbuffered_query</pre>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/04/27/mysql-statements-clauses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL commands</title>
		<link>http://edvanta.com/knowledgebase/2010/04/27/mysql-commands/</link>
		<comments>http://edvanta.com/knowledgebase/2010/04/27/mysql-commands/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 08:09:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=137</guid>
		<description><![CDATA[This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. [...]]]></description>
			<content:encoded><![CDATA[<p>This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.</p>
<p>Below when you see # it means from the unix shell. When you see mysql&gt; it means from a MySQL prompt after logging into MySQL.</p>
<h4>To login (from unix shell) use -h only if needed.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysql -h hostname -u root -p</p>
<h4>Create a database on the sql server.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; create database [databasename];</p>
<h4>List all databases on the sql server.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; show databases;</p>
<h4>Switch to a database.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; use [db name];</p>
<h4>To see all the tables in the db.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; show tables;</p>
<h4>To see database&#8217;s field formats.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; describe [table name];</p>
<h4>To delete a db.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; drop database [database name];</p>
<h4>To delete a table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; drop table [table name];</p>
<h4>Show all data in a table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name];</p>
<h4>Returns the columns and column information pertaining to the designated table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; show columns from [table name];</p>
<h4>Show certain selected rows with the value &#8220;whatever&#8221;.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE [field name] = &#8220;whatever&#8221;;</p>
<h4>Show all records containing the name &#8220;Bob&#8221; AND the phone number &#8216;3444444&#8242;.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE name = &#8220;Bob&#8221; AND phone_number = &#8216;3444444&#8242;;</p>
<h4>Show all records not containing the name &#8220;Bob&#8221; AND the phone number &#8216;3444444&#8242; order by the phone_number field.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE name != &#8220;Bob&#8221; AND phone_number = &#8216;3444444&#8242; order by phone_number;</p>
<h4>Show all records starting with the letters &#8216;bob&#8217; AND the phone number &#8216;3444444&#8242;.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE name like &#8220;Bob%&#8221; AND phone_number = &#8216;3444444&#8242;;</p>
<h4>Show all records starting with the letters &#8216;bob&#8217; AND the phone number &#8216;3444444&#8242; limit to records 1 through 5.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE name like &#8220;Bob%&#8221; AND phone_number = &#8216;3444444&#8242; limit 1,5;</p>
<h4>Use a regular expression to find records. Use &#8220;REGEXP BINARY&#8221; to force case-sensitivity. This finds any record beginning with a.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT * FROM [table name] WHERE rec RLIKE &#8220;^a&#8221;;</p>
<h4>Show unique records.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT DISTINCT [column name] FROM [table name];</p>
<h4>Show selected records sorted in an ascending (asc) or descending (desc).</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;</p>
<h4>Return number of rows.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT COUNT(*) FROM [table name];</p>
<h4>Sum column.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; SELECT SUM(*) FROM [table name];</p>
<h4>Join tables on common columns.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;</p>
<h4>Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; INSERT INTO user (Host,User,Password) VALUES(&#8217;%',&#8217;username&#8217;,PASSWORD(&#8217;password&#8217;));<br />
mysql&gt; flush privileges;</p>
<h4>Change a users password from unix shell.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password &#8216;new-password&#8217;</p>
<h4>Change a users password from MySQL prompt. Login as root. Set the password. Update privs.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysql -u root -p<br />
mysql&gt; SET PASSWORD FOR &#8216;user&#8217;@'hostname&#8217; = PASSWORD(&#8217;passwordhere&#8217;);<br />
mysql&gt; flush privileges;</p>
<h4>Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># /etc/init.d/mysql stop<br />
# mysqld_safe &#8211;skip-grant-tables &amp;<br />
# mysql -u root<br />
mysql&gt; use mysql;<br />
mysql&gt; update user set password=PASSWORD(&#8221;newrootpassword&#8221;) where User=&#8217;root&#8217;;<br />
mysql&gt; flush privileges;<br />
mysql&gt; quit<br />
# /etc/init.d/mysql stop<br />
# /etc/init.d/mysql start</p>
<h4>Set a root password if there is on root password.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysqladmin -u root password newpassword</p>
<h4>Update a root password.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysqladmin -u root -p oldpassword newpassword</p>
<h4>Allow the user &#8220;bob&#8221; to connect to the server from localhost using the password &#8220;passwd&#8221;. Login as root. Switch to the MySQL db. Give privs. Update privs.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; grant usage on *.* to bob@localhost identified by &#8216;passwd&#8217;;<br />
mysql&gt; flush privileges;</p>
<h4>Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># mysql -u root -p<br />
mysql&gt; use mysql;<br />
mysql&gt; INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES (&#8217;%',&#8217;databasename&#8217;,'username&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'N&#8217;);<br />
mysql&gt; flush privileges;</p>
<p>or</p>
<p>mysql&gt; grant all privileges on databasename.* to username@localhost;<br />
mysql&gt; flush privileges;</p>
<h4>To update info already in a table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; UPDATE [table name] SET Select_priv = &#8216;Y&#8217;,Insert_priv = &#8216;Y&#8217;,Update_priv = &#8216;Y&#8217; where [field name] = &#8216;user&#8217;;</p>
<h4>Delete a row(s) from a table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; DELETE from [table name] where [field name] = &#8216;whatever&#8217;;</p>
<h4>Update database permissions/privilages.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; flush privileges;</p>
<h4>Delete a column.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] drop column [column name];</p>
<h4>Add a new column to db.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] add column [new column name] varchar (20);</p>
<h4>Change column name.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] change [old column name] [new column name] varchar (50);</p>
<h4>Make a unique column so you get no dupes.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] add unique ([column name]);</p>
<h4>Make a column bigger.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] modify [column name] VARCHAR(3);</p>
<h4>Delete unique from table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; alter table [table name] drop index [colmn name];</p>
<h4>Load a CSV file into a table.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; LOAD DATA INFILE &#8216;/tmp/filename.csv&#8217; replace INTO TABLE [table name] FIELDS TERMINATED BY &#8216;,&#8217; LINES TERMINATED BY &#8216;\n&#8217; (field1,field2,field3);</p>
<h4>Dump all databases for backup. Backup file is sql commands to recreate all db&#8217;s.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysqldump -u root -ppassword &#8211;opt &gt;/tmp/alldatabases.sql</p>
<h4>Dump one database for backup.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysqldump -u username -ppassword &#8211;databases databasename &gt;/tmp/databasename.sql</p>
<h4>Dump a table from a database.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename &gt; /tmp/databasename.tablename.sql</p>
<h4>Restore database (or database table) from backup.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;"># [mysql dir]/bin/mysql -u username -ppassword databasename &lt; /tmp/databasename.sql</p>
<h4>Create Table Example 1.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));</p>
<h4>Create Table Example 2.</h4>
<p style="background-color: #ffffff; line-height: 1.1em; font: italic normal 600 12px/normal 'Courier New', Courier, mono; padding: 10px; border: 1px dashed #0000ff;">mysql&gt; create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default &#8216;bato&#8217;);</p>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/04/27/mysql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with GIT</title>
		<link>http://edvanta.com/knowledgebase/2010/03/12/working-with-git/</link>
		<comments>http://edvanta.com/knowledgebase/2010/03/12/working-with-git/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 13:20:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=99</guid>
		<description><![CDATA[We were an SVN Fan over CVS for the fact that it was so simple to use until we found Git which was faster and much powerful. Git allows faster version control in a distributed development environment. It has full fledged repository and efficient tracking capabilities. Branching, Merging or Cloning; any activity was smooth, fast [...]]]></description>
			<content:encoded><![CDATA[<p>We were an SVN Fan over CVS for the fact that it was so simple to use until we found Git which was faster and much powerful. Git allows faster version control in a distributed development environment. It has full fledged repository and efficient tracking capabilities. Branching, Merging or Cloning; any activity was smooth, fast and reliable.</p>
<p>Most of our development work is done on Moodle. So we chose Moodle repository to clone and play with.</p>
<p>To install git on our linux servers<br />
<code><br />
#yum install git-core gitk<br />
</code><br />
To Create a git repository create the folders<br />
<code><br />
#mkdir /git<br />
#cd /git/<br />
#mkdir moodle.git<br />
#cd moodle.git/<br />
</code></p>
<p>Lets Initialize a blank repository<br />
<code><br />
#git init --bare --shared=group<br />
</code><br />
Fetch Moodle versions &#8211; The same command be run in cron to update at an hourly basis<br />
<code><br />
#git --bare fetch git://git.moodle.org/moodle.git cvshead:cvshead#git --bare fetch git://git.moodle.org/moodle.git MOODLE_19_STABLE:MOODLE_19_STABLE</code></p>
<p><code> </code></p>
<p>Make a working copy</p>
<p><code><br />
#cd /var/www/html/<br />
#git clone file:///git/moodle.git moodlegit<br />
Initialized empty Git repository in /var/www/html/moodlegit/.git/<br />
remote: Counting objects: 354671, done.<br />
remote: Compressing objects: 100% (89253/89253), done.<br />
remote: Total 354671 (delta 261661), reused 352647 (delta 259667)<br />
Receiving objects: 100% (354671/354671), 144.86 MiB | 8.50 MiB/s, done.<br />
Resolving deltas: 100% (261661/261661), done.<br />
warning: remote HEAD refers to nonexistent ref, unable to checkout.<br />
</code><br />
I got an error and check out fails &#8212; Warning: Remote HEAD refers to nonexistent ref, unable to checkout. Which means it tries to setup a tracking branch that is not there in your local repository.</p>
<p><code><br />
#cd moodle19git/#git branch -r  ---- When i used this command it showed me two hidden directories for cvshead and MOODLE_19_STABLE</code></p>
<p><code> </code></p>
<p>You can do away with this warning by issuing command #git branch master which in this case will be the command below. This will switch it to the master branch.</p>
<p><code><br />
#git branch cvshead<br />
</code></p>
<p>Now I checked out the two branches</p>
<p><code><br />
#git checkout -b MOODLE_19_STABLE origin/MOODLE_19_STABLE#git checkout -b cvshead origin/cvshead</code></p>
<p><code> </code></p>
<p>Next I created a new branch for edvanta for customizing moodle 1.9+ for a project</p>
<p><code><br />
#git checkout -b mdl19-edvanta origin/MOODLE_19_STABLE<br />
</code></p>
<p>Now we can any changes on this. and then push it back to the server so that other developers can use it.</p>
<p><code><br />
#git push origin mdl19-edvanta:mdl19-edvanta<br />
</code></p>
<p>Now others can take my code and work with it on their system locally like this</p>
<p><code><br />
#git clone file:///git/moodle.git moodlegit<br />
#cd moodlegit<br />
#git checkout -b mdl19-edvanta origin/md19-edvanta<br />
</code></p>
<p>Once they have made their changes they can chose to publish their work to the main repository.</p>
<p><code><br />
#git add<br />
#git commit -a -m "Changes made by the third party developer"<br />
#git push origin/mdl19-edvanta mdl19-edvanta<br />
</code></p>
<p>To export to moodle2 directory without .git folders<br />
<code><br />
#git checkout-index -a -f --prefix=/var/www/html/moodle2/<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2010/03/12/working-with-git/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing postgresql on fedora&#8230;</title>
		<link>http://edvanta.com/knowledgebase/2009/10/19/installing-postgresql-on-fedora/</link>
		<comments>http://edvanta.com/knowledgebase/2009/10/19/installing-postgresql-on-fedora/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 19:27:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[postgre]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://edvanta.com/knowledgebase/?p=77</guid>
		<description><![CDATA[List all the packages
#yum list &#124; grep "postgres*"

#yum install -y "postgres*"

To initialize the postgresql

#service postgresql initdb

To start the postgresql service

#service postgresql start

Editing config files and creating new databases using pgadmin3 gui


#yum install -y pgadmin3

pgadmin gets install in /usr/bin/pgadmin3
To run pgadmin3

#pgadmin3

Add server, choose any name, host = localhost, user= postgres, password = &#8221; For others choose [...]]]></description>
			<content:encoded><![CDATA[<p>List all the packages</p>
<pre>#yum list | grep "postgres*"

#yum install -y "postgres*"
</pre>
<p>To initialize the postgresql</p>
<pre>
#service postgresql initdb
</pre>
<p>To start the postgresql service</p>
<pre>
#service postgresql start
</pre>
<p><strong>Editing config files and creating new databases using pgadmin3 gui<br />
</strong></p>
<pre>
#yum install -y pgadmin3
</pre>
<p>pgadmin gets install in /usr/bin/pgadmin3</p>
<p>To run pgadmin3</p>
<pre>
#pgadmin3
</pre>
<p>Add server, choose any name, host = localhost, user= postgres, password = &#8221; For others choose default settings and click okay.</p>
<p>Now create a new database<br />
Database name: new_database<br />
user: postgres<br />
pass: &#8221;</p>
<p>click okay and your good to go.</p>
<p><strong>editing config files and creating databases using a terminal</strong></p>
<p>Edit pg_hba.conf in /var/lib/pgsql/data and change the </p>
<pre>
#vim /var/lib/pgsql/data/pg_hba.conf
</pre>
<p>This setting</p>
<pre>
ipv4 local all all ident sameuser
</pre>
<p>to this</p>
<pre>
ipv4 local all all trust sameuser
</pre>
<p>To change other settings you can edit postgresql.conf</p>
<pre>
#vim /var/lib/pgsql/data/postgresql.conf
</pre>
]]></content:encoded>
			<wfw:commentRss>http://edvanta.com/knowledgebase/2009/10/19/installing-postgresql-on-fedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

