<?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>A R U N &#187; commands for mysql</title>
	<atom:link href="http://a-r-u-n.com/b/index.php/tag/commands-for-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://a-r-u-n.com/b</link>
	<description>....God&#039;s own website....</description>
	<lastBuildDate>Sun, 05 Sep 2010 11:23:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>mysql command line administration</title>
		<link>http://a-r-u-n.com/b/index.php/2009/10/mysql-command-line-administration/</link>
		<comments>http://a-r-u-n.com/b/index.php/2009/10/mysql-command-line-administration/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 13:05:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[commands for mysql]]></category>
		<category><![CDATA[mysql command line administration]]></category>

		<guid isPermaLink="false">http://a-r-u-n.com/b/?p=325</guid>
		<description><![CDATA[MySQL command line administration- 1. Login to server- Goto MySQL installed location through command prompt- C:\MySQL\bin or C:\Program files\MySQL\bin Specify MySQL user and password - C:\MySQl\bin&#62; mysql -u root -p Above command is used to login to local MySQL server. If you want to login to remote MySQL server use this command C:\MySQl\bin&#62; mysql -h [...]]]></description>
			<content:encoded><![CDATA[<p><strong>MySQL command line administration-</strong></p>
<p><em><strong>1. Login to server-</strong></em></p>
<p>Goto MySQL installed location through command prompt-</p>
<p><em>C:\MySQL\bin</em></p>
<p>or</p>
<p><em>C:\Program files\MySQL\bin</em></p>
<p>Specify MySQL user and password -</p>
<p><em>C:\MySQl\bin&gt; mysql -u root -p</em></p>
<p>Above command is used to login to local MySQL server. If you want to login to remote MySQL server use this command</p>
<p><em>C:\MySQl\bin&gt; mysql -h &lt;specify-remote-mysql-server-name-or-ip&gt; -u root -p</em></p>
<p><em><strong>2. List all the databases in MySQL server-</strong></em></p>
<p><em>mysql&gt; show databases;</em></p>
<p><em><strong>3. Create new database in MySQL server-</strong></em></p>
<p><em>mysql&gt; create database &lt;specify-db-name-here&gt;;</em></p>
<p><em><strong>4. Create a table in a database-</strong></em></p>
<p><em>create table `&lt;specify-table-name-here&gt;` (`field1` type , `field2` type);</em></p>
<p>For example- To create a table &#8216;fortest&#8217; with 3 fields &#8211; testid, testname, testemail-</p>
<p><em>mysql&gt; create table `fortest` (`testid` int( 11 ) not null auto_increment , `testname` varchar( 50 ) not null , `testemail` varchar( 100 ) not null , primary key ( `testid` ));<br />
</em><br />
<em><strong>5. To access a particular database in MySQL server-</strong></em></p>
<p><em>mysql&gt; use &lt;specify-db-name-here&gt;;</em></p>
<p>for example-</p>
<p><em>mysql&gt; use test;</em></p>
<p><em><strong>6. To view all the tables in that particular database-</strong></em></p>
<p><em>mysql&gt; show tables;</em></p>
<p><em><strong>7. To view that particular database&#8217;s table field format-</strong></em></p>
<p><em>mysql&gt; desc &lt;specify-table-name-here&gt;;<br />
</em><br />
for example-</p>
<p><em>mysql&gt; desc fortest;</em></p>
<p><em><strong>8. To access all the contents in a table-</strong></em></p>
<p><em>mysql&gt; select * from &lt;specify-table-name-here&gt;;</em></p>
<p>for example-</p>
<p><em>mysql&gt; select * from fortest;</em></p>
<p><em><strong>9. To retrieve specific info from particular table-<br />
</strong></em><br />
<em>mysql&gt; select * from &lt;specify-table-name-here&gt; where &lt;specify-field-name-here&gt; = &#8216;any-info&#8217;;</em></p>
<p>for example &#8211; if you want to find the details of a person named &#8216;arun&#8217; from the table &#8216;fortest&#8217; -</p>
<p><em>mysql&gt; select * from fortest where testname = &#8216;arun&#8217;;</em></p>
<p><strong><em>10. To create user in MySQL server-</em></strong></p>
<p><em>mysql&gt; create user &lt;specify-user-name-here&gt; identified by &#8216;&lt;specify-password-here&gt;&#8217;;</em></p>
<p>for example-</p>
<p><em>mysql&gt; create user &#8216;testinguser&#8217;@'%&#8217; identified by &#8216;testingpassword&#8217;;</em></p>
<p>alternate method-</p>
<p>You can create through mysql database-</p>
<p><em>mysql&gt; use mysql;<br />
Database changed<br />
mysql&gt; insert into user (host,user,password) values (&#8216;%&#8217;,'testinguser&#8217;,password(&#8216;testingpassword&#8217;));<br />
Query OK, 1 row affected (0.19 sec)</p>
<p>mysql&gt; flush privileges;</em></p>
<p><strong><em>11. Change password for a user-</em></strong></p>
<p><em>mysql&gt; set password for &#8216;user-name&#8217;@'hostname&#8217; = password(&#8216;specify-password-here&#8217;);<br />
</em><br />
<strong><em>12. To assign database specific privileges-</em></strong></p>
<p>All privileges to a particular database-</p>
<p><em>mysql&gt; grant all privileges on `test` . * to &#8216;testinguser1&#8242;@&#8217;%&#8217; with grant option ;</em></p>
<p>Specific privileges to a particular database-</p>
<p><em>mysql&gt; grant select , insert , update , delete , create , drop , index , alter , on `fortest` . * to &#8216;testinguser&#8217;@'%&#8217;;<br />
</em><br />
Alternate method-</p>
<p><em>mysql&gt; insert into user (host,db,user,select_priv,insert_priv,update_priv,delete_priv,create_priv,drop_priv) values (&#8216;%&#8217;,'specify-db-name-here&#8217;,'specify-user-name-here&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'y&#8217;);</p>
<p>mysql&gt; use mysql;<br />
Database changed<br />
mysql&gt; insert into user (host,db,user,select_priv,insert_priv,update_priv,delete_priv,create_priv,drop_priv) values (&#8216;%&#8217;,'test&#8217;,'testinguser&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'y&#8217;,'n&#8217;);</em></p>
<p><strong><em>13. To remove privileges for a particular user from a database-</em></strong></p>
<p><em>mysql&gt; revoke all privileges on `test` . * from &#8216;testinguser&#8217;@'%&#8217;;</em></p>
<p><strong><em>14. To delete a particular table-</em></strong></p>
<p><em>mysql&gt; drop table `fortest` ;</em></p>
<p><em><strong>15. To delete a particular database-</strong></em></p>
<p><em>mysql&gt; drop database `test` ;</em></p>
<p><strong><em>16. Backup the database-</em></strong></p>
<p><em>C:\MySQL\bin&gt; mysqldump -u root -p &lt;database-name&gt; &gt; C:\backup\test.sql</em></p>
<p><strong><em>17. Backup particular table from the database-</em></strong></p>
<p><em>C:\MySQL\bin&gt; mysqldump -u root -p &lt;database-name&gt; &lt;table-name&gt; &gt; C:\backup\fortest.sql</em></p>
<p><strong><em>18. Restore a database from the backup-</em></strong></p>
<p><em>C:\MySQL\bin&gt; mysql -u root -p &lt;database-name&gt; &lt; C:\backup\test.sql</em></p>
<div><span style="font-family: Verdana; color: #ff0000;"><span style="font-size: small;"><span style="color: #007f40;">&#8220;`</span><span style="color: #ff0000;">*</span><span style="color: #007f40;"><strong>&#8220;`</strong></span><span style="font-family: verdana; color: #ff0000;"><strong>a</strong>run</span></span></span><img src="http://us.i1.yimg.com/us.yimg.com/i/mesg/tsmileys2/40.gif" alt="" /> <strong><span style="font-family: comic sans ms; color: #ff0000; font-size: medium;">&#8230;</span></strong></div>
]]></content:encoded>
			<wfw:commentRss>http://a-r-u-n.com/b/index.php/2009/10/mysql-command-line-administration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
