<?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>Linux Ask! &#187; Databases</title>
	<atom:link href="http://www.linuxask.com/topics/databases/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxask.com</link>
	<description>Linux Ask! is a Q &#38; A web site specific for Linux related questions such as how to use common Linux commands.</description>
	<lastBuildDate>Sat, 04 Feb 2012 05:57:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Show the current privileges of a MySQL user</title>
		<link>http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user</link>
		<comments>http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user#comments</comments>
		<pubDate>Sat, 24 Sep 2011 13:28:13 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3484</guid>
		<description><![CDATA[Show the current privileges of a MySQL user Answer: To show the current privileges of a MySQL user, you can use the SHOW GRANTS statement E.g. mysql&#62; SHOW GRANTS; +----------------------------------------------------------------------------------------------------------------------------------------+ &#124; Grants for root@localhost &#124; +----------------------------------------------------------------------------------------------------------------------------------------+ &#124; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*****************************************' WITH GRANT OPTION &#124; +----------------------------------------------------------------------------------------------------------------------------------------+ Related posts: <a href='http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/how-to-create-a-new-mysql-user' rel='bookmark' title='How to create a new MySQL user?'>How to create a new MySQL user?</a></li>
<li><a href='http://www.linuxask.com/questions/show-the-current-user-in-mysql' rel='bookmark' title='Show the current user in MySQL'>Show the current user in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/reset-mysql-root-password' rel='bookmark' title='Reset MySQL root password'>Reset MySQL root password</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Show the current privileges of a MySQL user</p>
<p><strong>Answer:</strong></p>
<p>To show the current privileges of a <strong>MySQL </strong>user, you can use the <strong>SHOW GRANTS</strong> statement</p>
<p>E.g.</p>
<pre><code>mysql&gt; SHOW GRANTS;

+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*****************************************' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+</code></pre>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/how-to-create-a-new-mysql-user' rel='bookmark' title='How to create a new MySQL user?'>How to create a new MySQL user?</a></li>
<li><a href='http://www.linuxask.com/questions/show-the-current-user-in-mysql' rel='bookmark' title='Show the current user in MySQL'>Show the current user in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/reset-mysql-root-password' rel='bookmark' title='Reset MySQL root password'>Reset MySQL root password</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show the current user in MySQL</title>
		<link>http://www.linuxask.com/questions/show-the-current-user-in-mysql</link>
		<comments>http://www.linuxask.com/questions/show-the-current-user-in-mysql#comments</comments>
		<pubDate>Fri, 16 Sep 2011 13:37:37 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3489</guid>
		<description><![CDATA[Show the current user in MySQL Answer: Like in the shell, we can execute the command whoami to find out the current user name, we can use the function CURRENT_USER(); E.g. mysql&#62; SELECT CURRENT_USER(); +----------------+ &#124; CURRENT_USER() &#124; +----------------+ &#124; root@localhost &#124; +----------------+ 1 row in set (0.00 sec) Related posts: Show the current privileges <a href='http://www.linuxask.com/questions/show-the-current-user-in-mysql'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user' rel='bookmark' title='Show the current privileges of a MySQL user'>Show the current privileges of a MySQL user</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-create-a-new-mysql-user' rel='bookmark' title='How to create a new MySQL user?'>How to create a new MySQL user?</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-delete-mysql-user' rel='bookmark' title='How to delete MySQL user?'>How to delete MySQL user?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Show the current user in MySQL</p>
<p><strong>Answer:</strong></p>
<p>Like in the shell, we can execute the command <strong><a href="http://www.linuxask.com/questions/display-current-login-user-information">whoami </a></strong>to find out the current user name, we can use the function <strong>CURRENT_USER()</strong>;</p>
<p>E.g.</p>
<pre><code>mysql&gt; SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)</code></pre>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/show-the-current-privileges-of-a-mysql-user' rel='bookmark' title='Show the current privileges of a MySQL user'>Show the current privileges of a MySQL user</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-create-a-new-mysql-user' rel='bookmark' title='How to create a new MySQL user?'>How to create a new MySQL user?</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-delete-mysql-user' rel='bookmark' title='How to delete MySQL user?'>How to delete MySQL user?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/show-the-current-user-in-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select a document in MongoDB</title>
		<link>http://www.linuxask.com/questions/select-a-document-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/select-a-document-in-mongodb#comments</comments>
		<pubDate>Tue, 06 Sep 2011 10:50:38 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3454</guid>
		<description><![CDATA[Select a document in MongoDB Answer: To select (find) a document in MongoDB, you can use the following syntax in the mongodb Interactive shell. use my_db db.users.find({name:"peter"}) You need to switch to the current database (e.g. my_db) and then execute your select statement. Related posts: Insert a new document to MongoDB Create an index on <a href='http://www.linuxask.com/questions/select-a-document-in-mongodb'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/insert-a-new-document-to-mongodb' rel='bookmark' title='Insert a new document to MongoDB'>Insert a new document to MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb' rel='bookmark' title='Create an index on a document in MongoDB'>Create an index on a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Select a document in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>To select (find) a document in <strong>MongoDB</strong>, you can use the following syntax in the mongodb Interactive shell.</p>
<pre><code>use my_db
db.users.find({name:"peter"})</code></pre>
<p>You need to switch to the current database (e.g. my_db) and then execute your select statement.</p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/insert-a-new-document-to-mongodb' rel='bookmark' title='Insert a new document to MongoDB'>Insert a new document to MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb' rel='bookmark' title='Create an index on a document in MongoDB'>Create an index on a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/select-a-document-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explain query execution plan in MongoDB</title>
		<link>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb#comments</comments>
		<pubDate>Fri, 02 Sep 2011 14:20:19 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3450</guid>
		<description><![CDATA[Explain query execution plan in MongoDB Answer: Like MySQL, you can get a better understanding of the performance of your MongoDB's query, you can use the $explain feature. E.g. db.collection.find(query).explain(); Related posts: Explain query execution plan in MySQL Drop a collection in MongoDB Count the total number of objects in the collection in MongoDB
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql' rel='bookmark' title='Explain query execution plan in MySQL'>Explain query execution plan in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/drop-a-collection-in-mongodb' rel='bookmark' title='Drop a collection in MongoDB'>Drop a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb' rel='bookmark' title='Count the total number of objects in the collection in MongoDB'>Count the total number of objects in the collection in MongoDB</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Explain query execution plan in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>Like <a href="http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql">MySQL</a>, you can get a better understanding of the performance of your <strong>MongoDB's</strong> query, you can use the <strong>$explain</strong> feature.</p>
<p>E.g.</p>
<pre><code>db.collection.find(query).explain();</code></pre>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/explain-query-execution-plan-in-mysql' rel='bookmark' title='Explain query execution plan in MySQL'>Explain query execution plan in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/drop-a-collection-in-mongodb' rel='bookmark' title='Drop a collection in MongoDB'>Drop a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb' rel='bookmark' title='Count the total number of objects in the collection in MongoDB'>Count the total number of objects in the collection in MongoDB</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/explain-query-execution-plan-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable MySQL server from listening for TCP/IP connections</title>
		<link>http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections</link>
		<comments>http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections#comments</comments>
		<pubDate>Thu, 25 Aug 2011 13:51:20 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3408</guid>
		<description><![CDATA[Disable MySQL server from listening for TCP/IP connections Answer: If you only connect to the MySQL server from localhost and you might want to disable TCP/IP networking feature so the server is more secure. To do so, edit the MySQL configurations, e.g. /etc/my.cnf .. skip-networking .. Don't forget to restart MySQL to take effect. # <a href='http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/disable-dns-hostname-lookup-in-mysql' rel='bookmark' title='Disable DNS hostname lookup in MySQL'>Disable DNS hostname lookup in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/turn-off-innodb-support-in-mysql' rel='bookmark' title='Turn off InnoDB support in MySQL'>Turn off InnoDB support in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/set-the-maximum-allowed-number-of-connections-in-mysql' rel='bookmark' title='Set the maximum allowed number of connections in MySQL'>Set the maximum allowed number of connections in MySQL</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Disable MySQL server from listening for TCP/IP connections</p>
<p><strong>Answer:</strong></p>
<p>If you only connect to the MySQL server from localhost and you might want to disable TCP/IP networking feature so the server is more secure.</p>
<p>To do so, edit the MySQL configurations, e.g. <strong>/etc/my.cnf</strong></p>
<pre><code>..
skip-networking
..</code></pre>
<p>Don't forget to <strong>restart </strong>MySQL to take effect.</p>
<p><code># /sbin/service mysqld restart</code></p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/disable-dns-hostname-lookup-in-mysql' rel='bookmark' title='Disable DNS hostname lookup in MySQL'>Disable DNS hostname lookup in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/turn-off-innodb-support-in-mysql' rel='bookmark' title='Turn off InnoDB support in MySQL'>Turn off InnoDB support in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/set-the-maximum-allowed-number-of-connections-in-mysql' rel='bookmark' title='Set the maximum allowed number of connections in MySQL'>Set the maximum allowed number of connections in MySQL</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repair and compact database in MongoDB</title>
		<link>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb#comments</comments>
		<pubDate>Fri, 19 Aug 2011 14:15:26 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3315</guid>
		<description><![CDATA[Repair and compact database in MongoDB Answer: To repair and compact a database in MongoDB, you can use the following command in the mongodb Interactive shell. 1. Select the database use test 2. Repair the current database db.repairDatabase() Done. Related posts: Drop a database in MongoDB Select a document in MongoDB Repair table in MySQL
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/drop-a-database-in-mongodb' rel='bookmark' title='Drop a database in MongoDB'>Drop a database in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/select-a-document-in-mongodb' rel='bookmark' title='Select a document in MongoDB'>Select a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/repair-table-in-mysql' rel='bookmark' title='Repair table in MySQL'>Repair table in MySQL</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Repair and compact database in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>To repair and compact a database in <strong>MongoDB</strong>, you can use the following command in the mongodb Interactive shell.</p>
<p>1. Select the database</p>
<p><code>use test</code></p>
<p>2. Repair the current database</p>
<p><code>db.repairDatabase()</code></p>
<p>Done.</p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/drop-a-database-in-mongodb' rel='bookmark' title='Drop a database in MongoDB'>Drop a database in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/select-a-document-in-mongodb' rel='bookmark' title='Select a document in MongoDB'>Select a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/repair-table-in-mysql' rel='bookmark' title='Repair table in MySQL'>Repair table in MySQL</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count the total number of objects in the collection in MongoDB</title>
		<link>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb#comments</comments>
		<pubDate>Wed, 17 Aug 2011 14:11:22 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3311</guid>
		<description><![CDATA[Count the total number of objects in the collection in MongoDB Answer: In MongoDB, to count the total number of objects in the collection, you can use the following statement in the mongodb Interactive shell. db.test.count() The above statement will return the total number of objects in the collection "test" Related posts: Count the total <a href='http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/count-the-total-number-of-logged-in-user' rel='bookmark' title='Count the total number of logged in user'>Count the total number of logged in user</a></li>
<li><a href='http://www.linuxask.com/questions/drop-a-collection-in-mongodb' rel='bookmark' title='Drop a collection in MongoDB'>Drop a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Count the total number of objects in the collection in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In <strong>MongoDB</strong>, to count the total number of objects in the collection, you can use the following statement in the mongodb Interactive shell.</p>
<p><code>db.test.count()</code></p>
<p>The above statement will return the total number of objects in the collection "<strong>test</strong>"</p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/count-the-total-number-of-logged-in-user' rel='bookmark' title='Count the total number of logged in user'>Count the total number of logged in user</a></li>
<li><a href='http://www.linuxask.com/questions/drop-a-collection-in-mongodb' rel='bookmark' title='Drop a collection in MongoDB'>Drop a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/count-the-total-number-of-objects-in-the-collection-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creates an index in MongoDB</title>
		<link>http://www.linuxask.com/questions/creates-an-index-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/creates-an-index-in-mongodb#comments</comments>
		<pubDate>Mon, 15 Aug 2011 14:06:57 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3309</guid>
		<description><![CDATA[Creates an index in MongoDB Answer: In an given collection, if you want to add an index on a specify field, you can do the following in the mongodb Interactive shell. db.test.ensureIndex( { name : 1 } ) The key "name" from now on will have index enabled. Related posts: Create an index on a <a href='http://www.linuxask.com/questions/creates-an-index-in-mongodb'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb' rel='bookmark' title='Create an index on a document in MongoDB'>Create an index on a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb' rel='bookmark' title='Repair and compact database in MongoDB'>Repair and compact database in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Creates an index in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In an given collection, if you want to add an <strong>index </strong>on a specify field, you can do the following in the mongodb Interactive shell.</p>
<p><code>db.test.ensureIndex( { name : 1 } )</code></p>
<p>The key "name" from now on will have index enabled.</p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/create-an-index-on-a-document-in-mongodb' rel='bookmark' title='Create an index on a document in MongoDB'>Create an index on a document in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/repair-and-compact-database-in-mongodb' rel='bookmark' title='Repair and compact database in MongoDB'>Repair and compact database in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/creates-an-index-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show the storage used by a database in MySQL</title>
		<link>http://www.linuxask.com/questions/show-the-storage-used-by-a-database-in-mysql</link>
		<comments>http://www.linuxask.com/questions/show-the-storage-used-by-a-database-in-mysql#comments</comments>
		<pubDate>Thu, 11 Aug 2011 13:32:31 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3286</guid>
		<description><![CDATA[Show the storage used by a database in MySQL Answer: In previous article, we have already discussed how to list the database size in your MySQL server. But if you want to have a more detail view on an individual database, you can try the following (crazy) SQL. SELECT s.schema_name, CONCAT(IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length)) /1024/1024,2),0.00),"Mb") total_size, CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00),"Mb") data_used, <a href='http://www.linuxask.com/questions/show-the-storage-used-by-a-database-in-mysql'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/list-all-the-database-size-in-mysql' rel='bookmark' title='List all the database size in MySQL'>List all the database size in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/drop-all-tables-in-mysql-database' rel='bookmark' title='Drop all tables in MySQL database'>Drop all tables in MySQL database</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-rename-database-in-mysql' rel='bookmark' title='How to rename database in MySQL'>How to rename database in MySQL</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Show the storage used by a database in MySQL</p>
<p><strong>Answer:</strong></p>
<p>In <a href="http://www.linuxask.com/questions/list-all-the-database-size-in-mysql">previous article</a>, we have already discussed how to list the database size in your <strong>MySQL </strong>server.</p>
<p>But if you want to have a more detail view on an individual database, you can try the following (crazy) SQL.</p>
<pre><code>SELECT s.schema_name,
CONCAT(IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length))
/1024/1024,2),0.00),"Mb") total_size,
CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00),"Mb")

data_used,
CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00),"Mb") data_free,
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))
/((SUM(t.data_length)+SUM(t.index_length)))*100),2),0) pct_used,
COUNT(table_name) total_tables
FROM INFORMATION_SCHEMA.SCHEMATA s
LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema
WHERE s.schema_name = "mydatabase"
GROUP BY s.schema_name
ORDER BY pct_used DESC\G</code></pre>
<p>It will give you something like the following..</p>
<pre><code> schema_name: mydatabase
  total_size: 165.09Mb
   data_used: 12.09Mb
   data_free: 153.00Mb
    pct_used: 7.33
total_tables: 133</code></pre>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/list-all-the-database-size-in-mysql' rel='bookmark' title='List all the database size in MySQL'>List all the database size in MySQL</a></li>
<li><a href='http://www.linuxask.com/questions/drop-all-tables-in-mysql-database' rel='bookmark' title='Drop all tables in MySQL database'>Drop all tables in MySQL database</a></li>
<li><a href='http://www.linuxask.com/questions/how-to-rename-database-in-mysql' rel='bookmark' title='How to rename database in MySQL'>How to rename database in MySQL</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/show-the-storage-used-by-a-database-in-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update an existing document in MongoDB</title>
		<link>http://www.linuxask.com/questions/update-an-existing-document-in-mongodb</link>
		<comments>http://www.linuxask.com/questions/update-an-existing-document-in-mongodb#comments</comments>
		<pubDate>Thu, 21 Jul 2011 05:06:56 +0000</pubDate>
		<dc:creator>Linux Ask!</dc:creator>
				<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3216</guid>
		<description><![CDATA[Update an existing document in MongoDB Answer: In an given collection, if you want to perform update on an existing document, the easiest way is to use the following commands. employee = db.employees.findOne( { name : "Peter" } ); employee.position = "Project Manager"; db.employees.save( employee ); Done. Related posts: Remove a document in a collection <a href='http://www.linuxask.com/questions/update-an-existing-document-in-mongodb'>[...]</a>
Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/insert-a-new-document-to-mongodb' rel='bookmark' title='Insert a new document to MongoDB'>Insert a new document to MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/select-a-document-in-mongodb' rel='bookmark' title='Select a document in MongoDB'>Select a document in MongoDB</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Update an existing document in MongoDB</p>
<p><strong>Answer:</strong></p>
<p>In an given collection, if you want to perform <strong>update</strong> on an existing document, the easiest way is to use the following commands.</p>
<pre><code>employee = db.employees.findOne( { name : "Peter" } );
employee.position = "Project Manager";
db.employees.save( employee );</code></pre>
<p>Done.</p>
<p>Related posts:<ol>
<li><a href='http://www.linuxask.com/questions/remove-a-document-in-a-collection-in-mongodb' rel='bookmark' title='Remove a document in a collection in MongoDB'>Remove a document in a collection in MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/insert-a-new-document-to-mongodb' rel='bookmark' title='Insert a new document to MongoDB'>Insert a new document to MongoDB</a></li>
<li><a href='http://www.linuxask.com/questions/select-a-document-in-mongodb' rel='bookmark' title='Select a document in MongoDB'>Select a document in MongoDB</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/update-an-existing-document-in-mongodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

