<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>blazt.com &#187; MYSQL</title>
	<atom:link href="http://merlyscaria.wordpress.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://merlyscaria.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 15 Jul 2009 05:33:42 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='merlyscaria.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/c31d1c09edbc8e5b7c0729dceed093df?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>blazt.com &#187; MYSQL</title>
		<link>http://merlyscaria.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://merlyscaria.wordpress.com/osd.xml" title="blazt.com" />
		<item>
		<title>MYSQL</title>
		<link>http://merlyscaria.wordpress.com/2008/05/06/mysql/</link>
		<comments>http://merlyscaria.wordpress.com/2008/05/06/mysql/#comments</comments>
		<pubDate>Tue, 06 May 2008 04:17:53 +0000</pubDate>
		<dc:creator>merly</dc:creator>
				<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[create table +mysql]]></category>
		<category><![CDATA[GRANT privileges in mysql]]></category>
		<category><![CDATA[insert +mysq]]></category>
		<category><![CDATA[MYSQL back up]]></category>
		<category><![CDATA[MYSQL commands]]></category>
		<category><![CDATA[MYSQL DUMP]]></category>
		<category><![CDATA[MYSQl restore]]></category>
		<category><![CDATA[UPDATE table in mysql]]></category>

		<guid isPermaLink="false">http://merlyscaria.wordpress.com/?p=44</guid>
		<description><![CDATA[MYSQL COMMANDS
1)To login (from unix shell) use -h only if needed.
&#8212;-&#62;[mysql dir]/bin/mysql -h hostname -u root -p
***************************************************************
2)Create a database on the sql server.
&#8212;-&#62;  create database [databasename];
&#8212;-&#62;eg :- create database college;
****************************************************************
3)List all databases on the sql server.
&#8212;-&#62;   show databases;
*****************************************************************
4)Switch to a database.
&#8212;&#8211;&#62; use [databasename];
*****************************************************************
5)To see all the tables in the database.
&#8212;&#8212;-&#62;show tables
******************************************************************
6) To [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=merlyscaria.wordpress.com&blog=2300345&post=44&subd=merlyscaria&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>MYSQL COMMANDS</p>
<p>1)To login (from unix shell) use -h only if needed.<br />
&#8212;-&gt;[mysql dir]/bin/mysql -h hostname -u root -p</p>
<p>***************************************************************<br />
2)Create a database on the sql server.<br />
&#8212;-&gt;  create database [databasename];<br />
&#8212;-&gt;eg :- create database college;</p>
<p>****************************************************************<br />
3)List all databases on the sql server.<br />
&#8212;-&gt;   show databases;</p>
<p>*****************************************************************<br />
4)Switch to a database.<br />
&#8212;&#8211;&gt; use [databasename];</p>
<p>*****************************************************************<br />
5)To see all the tables in the database.<br />
&#8212;&#8212;-&gt;show tables</p>
<p>******************************************************************<br />
6) To see database&#8217;s field formats.<br />
&#8212;&#8211;&gt;  desc [table name];</p>
<p>*******************************************************************<br />
7)To delete a db.<br />
&#8212;&gt;  drop database [database name];<br />
eg:- drop database college;</p>
<p>******************************************************************<br />
8)To create a table.<br />
&#8212;&#8211;&gt;CREATE table tablename(field_one datatype(size),fiels_two datatype(size));</p>
<p>eg1:-mysql&gt; CREATE TABLE student( id INT(20),name VARCHAR(100));<br />
Query OK, 0 rows affected (0.03 sec)</p>
<p>eg:-2 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<br />
VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));<br />
*******************************************************************<br />
9)Creating a table with auto_increment</p>
<p>&#8212;&gt; CREATE TABLE  tablename(field_one datatype(size)  NOT NULL AUTO_INCREMENT PRIMARY KEY  , field_two datatype(size));</p>
<p>eg:-mysql&gt; CREATE TABLE student (id INT(10)  NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100)   );<br />
Query OK, 0 rows affected (0.01 sec)</p>
<p>*******************************************************************<br />
10)Creating a table with the current timestamp<br />
&#8212;&gt; CREATE TABLE student ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,<br />
data VARCHAR(100),  cur_timestamp TIMESTAMP(7)      );</p>
<p>*******************************************************************<br />
11Creating a table with TIMESTAMP DEFAULT NOW()</p>
<p>&#8212;&gt; CREATE TABLE student (<br />
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,<br />
name VARCHAR(100),  created TIMESTAMP DEFAULT NOW());</p>
<p>*******************************************************************<br />
12)Viewing a table definition<br />
&#8212;-&gt; DESC tablename;</p>
<p>*********************************************************************<br />
13)To delete a table.<br />
&#8212;&#8211;&gt; drop table [table name];<br />
eg) drop table student;</p>
<p>*********************************************************************<br />
14)INSERT  values into table<br />
&#8212;&#8211;&gt;INSERT INTO [tablename] (filed_one,field_two,feild_three) values(value1,value2,value3);</p>
<p>eg:-INSERT INTO student (id,name,branch) values(1,&#8217;Amit&#8217;,'computer science&#8217;);</p>
<p>*******************************************************************<br />
15)Change a users password.(from unix shell).<br />
&#8212;-&gt;mysql dir]/bin/mysqladmin -u root -h hostname.blah.org -p password &#8216;new-password&#8217;</p>
<p>******************************************************************<br />
16)Change a users password.(from MySQL prompt).<br />
&#8212;-&gt; SET PASSWORD FOR &#8216;user&#8217;@'hostname&#8217; = PASSWORD(&#8216;passwordhere&#8217;);</p>
<p>******************************************************************<br />
17)GRANT  privileges<br />
&#8212;&#8211;&gt;grant all privileges on [databasename].* to user@&#8217;localhost&#8217; identified by &#8216;passwd&#8217;;</p>
<p>******************************************************************<br />
18)GRANT specific privileges<br />
&#8212;-&gt; GRANT SELECT ON databasename.* TO username@&#8217;localhost&#8217; IDENTIFIED BY &#8216;password&#8217;;</p>
<p>To enable more options you would separate them with a comma. So to enable SELECT, INSERT, and DELETE your syntax would look like this;</p>
<p>&#8212;&#8211;&gt;GRANT SELECT, INSERT, DELETE ON database.* TO username@&#8217;localhost&#8217; IDENTIFIED BY &#8216;password&#8217;;</p>
<p>Once you have given the desired privileges for your user, you will need to run this command within the MySQL command prompt;</p>
<p>&#8212;&#8211;&gt;FLUSH PRIVILEGES;</p>
<p>To see a list of the privileges that have been granted to a specific user;</p>
<p>&#8212;&#8211;&gt; select * from MySQL.user where User=&#8217;user&#8217; \G</p>
<p>This is a list of privileges that you can grant;</p>
<table class="htmtableborders" style="display:table;height:878px;" border="1" cellspacing="1" cellpadding="1" width="567" align="center">
<tbody>
<tr>
<td align="center" valign="top">Privilege</td>
<td align="center" valign="top">Meaning</td>
</tr>
<tr>
<td valign="top">ALL [PRIVILEGES]</td>
<td align="left" valign="top">Sets all simple privileges except GRANT OPTION</td>
</tr>
<tr>
<td valign="top">ALTER</td>
<td valign="top">Enables use of ALTER TABLE</td>
</tr>
<tr>
<td valign="top">CREATE</td>
<td valign="top">Enables use of CREATE TABLE</td>
</tr>
<tr>
<td valign="top">CREATE TEMPORARY TABLES</td>
<td valign="top">Enables use of CREATE TEMPORARY TABLE</td>
</tr>
<tr>
<td valign="top">DELETE</td>
<td valign="top">Enables use of DELETE</td>
</tr>
<tr>
<td valign="top">DROP</td>
<td valign="top">Enables use of DROP TABLE</td>
</tr>
<tr>
<td valign="top">EXECUTE</td>
<td valign="top">Not implemented</td>
</tr>
<tr>
<td valign="top">FILE</td>
<td valign="top">Enables use of SELECT &#8230; INTO OUTFILE and LOAD DATA INFILE</td>
</tr>
<tr>
<td style="width:50%;">INDEX</td>
<td style="width:50%;">Enables use of CREATE INDEX and DROP INDEX</td>
</tr>
<tr>
<td style="width:50%;">INSERT</td>
<td style="width:50%;">Enables use of INSERT</td>
</tr>
<tr>
<td style="width:50%;">LOCK TABLES</td>
<td style="width:50%;">Enables use of LOCK TABLES on tables for which you have the SELECT privilege</td>
</tr>
<tr>
<td style="width:50%;">PROCESS</td>
<td style="width:50%;">Enables the user to see all processes with SHOW PROCESSLIST</td>
</tr>
<tr>
<td style="width:50%;">REFERENCES</td>
<td style="width:50%;">Not implemented</td>
</tr>
<tr>
<td style="width:50%;">RELOAD</td>
<td style="width:50%;">Enables use of FLUSH</td>
</tr>
<tr>
<td style="width:50%;">REPLICATION CLIENT</td>
<td style="width:50%;">Enables the user to ask where slave or master servers are</td>
</tr>
<tr>
<td style="width:50%;">REPLICATION SLAVE</td>
<td style="width:50%;">Needed for replication slaves (to read binary log events from the master)</td>
</tr>
<tr>
<td style="width:50%;">SELECT</td>
<td style="width:50%;">Enables use of SELECT</td>
</tr>
<tr>
<td style="width:50%;">SHOW DATABASES</td>
<td style="width:50%;">SHOW DATABASES shows all databases</td>
</tr>
<tr>
<td style="width:50%;">SHUTDOWN</td>
<td style="width:50%;">Enables use of MySQLadmin shutdown</td>
</tr>
<tr>
<td style="width:50%;">SUPER</td>
<td style="width:50%;">Enables use of CHANGE MASTER, KILL, PURGE MASTER LOGS, and SET GLOBAL statements, the MySQLadmin debug command; allows you to connect (once) even if max_connections is reached</td>
</tr>
<tr>
<td style="width:50%;">UPDATE</td>
<td style="width:50%;">Enables use of UPDATE</td>
</tr>
<tr>
<td style="width:50%;">USAGE</td>
<td style="width:50%;">Synonym for â€œno privilegesâ€</td>
</tr>
<tr>
<td style="width:50%;">GRANT OPTION</td>
<td style="width:50%;">Enables privileges to be granted</td>
</tr>
</tbody>
</table>
<p>********************************************************************<br />
19)To update info already in a table.<br />
&#8212;-&gt; Update table tablename  SET fieldname=newvalue where fieldname=oldvalue;<br />
eg1:-   Update  table  student set id=2 where id=2;<br />
eg2:-  Update table student set name=&#8217;Arun&#8217; where name=&#8217;Amit&#8217;;</p>
<p>********************************************************************<br />
20) Modify an existing field in a table<br />
&#8212;-&gt;  update table table name MODIFY fieldname(new size);<br />
eg:-  Update table tablename  MODIFY id(30);</p>
<p>********************************************************************<br />
21)Delete a row(s) from a table.<br />
&#8212;&gt; DELETE from [table name] where [field name] = &#8216;value&#8217;;</p>
<p>********************************************************************<br />
22)Delete a column.<br />
&#8212;-&gt;alter table [table name] drop column [column name];</p>
<p>*******************************************************************<br />
23)Add a new column to db.<br />
&#8212;&#8211;&gt; alter table [table name] add column [new column name] varchar (20);</p>
<p>***************************************************************<br />
24)Change column name.<br />
&#8212;-&gt; alter table [table name] change [old column name] [new column name] varchar (50);</p>
<p>*****************************************************************<br />
25)Make a unique column so you get no dupes.<br />
&#8212;-&gt; alter table [table name] add unique ([column name]);</p>
<p>******************************************************************<br />
26)Make a column bigger.<br />
&#8212;-&gt; alter table [table name] modify [column name] VARCHAR(3);</p>
<p>*****************************************************************<br />
27)Select values from a table</p>
<p>To see alla values of a table use</p>
<p>SELECT * from tablename;</p>
<p>To select specific values from a table use</p>
<p>SELECT fieldname_one,fieldname_two from tablename;</p>
<p>To select fields based on condition</p>
<p>SELECT  fieldname_one,fieldname_two from tablename where [condition];</p>
<p>eg:-SELECT id from student where name=&#8217;Arun&#8217;;</p>
<p>28 ) Dump a table from a database</p>
<p>[mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename &gt; /tmp/databasename.tablename.sql</p>
<p>29)Restore database (or database table) from backup.<br />
[mysql dir]/bin/mysql -u username -ppassword databasename &lt; /tmp/databasename.sql</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/merlyscaria.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/merlyscaria.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/merlyscaria.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/merlyscaria.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/merlyscaria.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/merlyscaria.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/merlyscaria.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/merlyscaria.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/merlyscaria.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/merlyscaria.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/merlyscaria.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/merlyscaria.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=merlyscaria.wordpress.com&blog=2300345&post=44&subd=merlyscaria&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://merlyscaria.wordpress.com/2008/05/06/mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/669e31be3d236b5be22af924547d7b5a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">merly</media:title>
		</media:content>
	</item>
	</channel>
</rss>