<?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>Sohail Riaz, Linux and Open Source Blog &#187; MySQL</title>
	<atom:link href="http://www.sohailriaz.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sohailriaz.com</link>
	<description>Sohail Riaz, Linux and Open Source Blog</description>
	<lastBuildDate>Sat, 14 Jan 2012 09:40:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HowTo Drop All Tables in MySQL Database Using BASH</title>
		<link>http://www.sohailriaz.com/howto-drop-all-tables-in-mysql-database-using-bash/</link>
		<comments>http://www.sohailriaz.com/howto-drop-all-tables-in-mysql-database-using-bash/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 10:17:26 +0000</pubDate>
		<dc:creator>Sohail Riaz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.sohailriaz.com/?p=135</guid>
		<description><![CDATA[<a href="http://www.sohailriaz.com/howto-drop-all-tables-in-mysql-database-using-bash/"><img src=""  alt="" title="" /></a>
In this howto i will describe how to execute MySQL commands on BASH shell and do more on results. The beauty of BASH is that you can developed a script which help you to do different, repeated and can execute different MySQL commands on result of previous MySQL command result. My primary example is to [...]]]></description>
			<content:encoded><![CDATA[<p>In this howto i will describe how to execute MySQL commands on BASH shell and do more on results. The beauty of BASH is that you can developed a script which help you to do different, repeated and can execute different MySQL commands on result of previous MySQL command result. My primary example is to drop all tables in MySQL database using BASH shell.<span id="more-135"></span></p>
<h3>1) Check Number of Databases.</h3>
<blockquote><p>mysql -u root -p&lt;rootpass&gt; -e &#8220;SHOW DATABASES&#8221;</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
 Database                       <br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
 information_schema<br />
 Randydb                       <br />
 test                                  <br />
 mysql                             <br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</p></blockquote>
<h3>2) Check the Number of Tables in a Database</h3>
<blockquote><p>mysql -u root -p&lt;rootpass&gt; -e &#8220;SHOW TABLES from mysql&#8221;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
 Tables_in_mysql          <br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
 columns_priv                <br />
 db                                        <br />
 func                                    <br />
 help_category               <br />
 help_keyword               <br />
 help_relation                 <br />
 help_topic                       <br />
 host                                    <br />
 proc                                   <br />
 procs_priv                      <br />
 tables_priv                     <br />
 time_zone                       <br />
 user                                    <br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+</p></blockquote>
<h3>3) Drop All Tables in a Database</h3>
<p>There is no single command for dropping all tables on mysql prompt. You can drop table one by one. To drop all tables we can script it using bash</p>
<blockquote><p>mysql -u root -p &lt;rootpass&gt; -e &#8220;SHOW TABLES FROM Randydb&#8221; | grep -v &#8220;Tables_in_Randydb&#8221; | while read a; do<br />
mysql -u root -p&lt;rootpass&gt; -e &#8220;DROP TABLE Randydb.$a&#8221;<br />
done</p></blockquote>
<p>The above script will drop all tables in Randydb. In this way you can create several small scripts to maintain / manage / monitor your MySQL. I am creating new mysql-bash scripts as per need and will post as soon as there is any new one.</p>
<img src="http://www.sohailriaz.com/wp-content/plugins/pixelstats/trackingpixel.php?post_id=135&amp;ts=1328437464" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://www.sohailriaz.com/howto-drop-all-tables-in-mysql-database-using-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Install MyTOP &#8211; a top clone for MySQL</title>
		<link>http://www.sohailriaz.com/how-to-install-mytop-a-top-clone-for-mysql/</link>
		<comments>http://www.sohailriaz.com/how-to-install-mytop-a-top-clone-for-mysql/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:57:54 +0000</pubDate>
		<dc:creator>Sohail Riaz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[YUM]]></category>

		<guid isPermaLink="false">http://www.sohailriaz.com/?p=112</guid>
		<description><![CDATA[<a href="http://www.sohailriaz.com/how-to-install-mytop-a-top-clone-for-mysql/"><img src=""  alt="" title="" /></a>
In this howto i will describe how to install mytop package on CentOS 5.3. MyTOP is top command clone to monitor mysql performance including queries, threads etc. You can get source of it from here to build or you can use rpmforge repositories for pre-build rpms. The machine i used to demonstrte is in production [...]]]></description>
			<content:encoded><![CDATA[<p>In this howto i will describe how to install mytop package on CentOS 5.3. MyTOP is top command clone to monitor mysql performance including queries, threads etc. You can get source of it from <a title="MyTOP Website" href="http://jeremy.zawodny.com/mysql/mytop/" target="_blank">here</a> to build or you can use rpmforge repositories for pre-build rpms. The machine i used to demonstrte is in production and getting very high mysql access, its running on CentOS 5.3.<span id="more-112"></span></p>
<h3>1 Setting Up RPMForge Repository</h3>
<p>RPMForge repository (http://dag.wieers.com) is the biggest rpm respository for RHEL, CentOS for all versions. To enable RPMForge respository run following command. The following command directly install rpm from http://dag.wieers.com site.</p>
<blockquote><p>rpm -Uhv <a href="http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm">http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm</a></p></blockquote>
<p>This rpm will add necessary files in our repository configuration and can be viewed at <strong>/etc/yum.repos.d/rpmforge.repo</strong></p>
<h3>2 Install MyTOP</h3>
<p>Use yum to install mytop on your machine</p>
<blockquote><p>yum -y install mytop</p></blockquote>
<p>It will install mytop with all necessary pre-requisite to run mytop.</p>
<h3>3 Running MyTOP</h3>
<p>To run use</p>
<blockquote><p>mytop</p></blockquote>
<p>if you have restricted access using password then</p>
<blockquote><p>mytop -u root -p &lt;password&gt; -h localhost</p></blockquote>
<p><strong><span style="color: #ff0000;">NOTE</span></strong>: You may get following error in CentOS 5.3<br />
<strong>Error in option spec: “long|!”</strong></p>
<p>To fix this do following.</p>
<blockquote><p>chmod 755 /usr/bin/mytop<br />
vi /usr/bin/mytop</p></blockquote>
<p>Search for the line</p>
<blockquote><p>&#8220;long|!&#8221;              =&gt; \$config{long_nums},</p></blockquote>
<p>Change it to by commenting using #</p>
<blockquote><p>#&#8221;long|!&#8221;              =&gt; \$config{long_nums},</p></blockquote>
<p>Now run the command again and it will run fine and you can see mytop giving all the information about you mysql server.</p>
<blockquote><p>mytop</p></blockquote>
<img src="http://www.sohailriaz.com/wp-content/plugins/pixelstats/trackingpixel.php?post_id=112&amp;ts=1328437464" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://www.sohailriaz.com/how-to-install-mytop-a-top-clone-for-mysql/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

