<?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>unexpected[it] &#187; Databases</title>
	<atom:link href="http://www.unexpectedit.com/category/databases/feed" rel="self" type="application/rss+xml" />
	<link>http://www.unexpectedit.com</link>
	<description>Professional IT Blog</description>
	<lastBuildDate>Tue, 31 Jan 2012 21:55:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL Settings for Magento Website</title>
		<link>http://www.unexpectedit.com/databases/mysql-settings-for-magento-website</link>
		<comments>http://www.unexpectedit.com/databases/mysql-settings-for-magento-website#comments</comments>
		<pubDate>Thu, 17 Jun 2010 14:19:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[configs]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[my.cnf]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=143</guid>
		<description><![CDATA[The last month we started having delays processing orders in the backend in a production e-Commerce Website. We adjusted the system to this config and we the website runs at a really good performance now. We calculated this values using this formula: key_buffer_size + (read_buffer_size + sort_buffer_size) * max_connections = Total Memory Website Details Magento [...]]]></description>
			<content:encoded><![CDATA[<p>The last month we started having delays processing orders in the backend in a production e-Commerce Website.<br />
We adjusted the system to this config and we the website runs at a really good performance now.</p>
<p>We calculated this values using this formula:<br />
key_buffer_size + (read_buffer_size + sort_buffer_size) * max_connections = Total Memory</p>
<p><strong>Website Details</strong><br />
Magento E-Commerce Website<br />
Running in a:<br />
Dell Server<br />
CPU cores: Two<br />
Processor(s): 1x Dual Xeon<br />
Clock Speed: &gt;= 2.33GHz<br />
RAM: 2 GBytes<br />
Disks: 1&#215;250 GB SATA</p>
<p>Managing:<br />
13.651 Orders in the last 6 months.<br />
24.403 Customers<br />
1.196 Products</p>
<p><a href="http://mysqltuner.pl/mysqltuner.pl" target="_blank">Download mysqltuner.pl</a><br />
More Info:<br />
The MySQL Performance Blog <a href="http://www.mysqlperformanceblog.com/2006/05/17/mysql-server-memory-usage/" target="_blank">http://www.mysqlperformanceblog.com/2006/05/17/mysql-server-memory-usage/</a><br />
Stack Overflow: <a href="http://stackoverflow.com/questions/1178736/mysql-maximum-memory-usage" target="_blank">http://stackoverflow.com/questions/1178736/mysql-maximum-memory-usage</a></p>
<p><strong>Reports</strong><br />
<code>#<br />
#<br />
# Default Configuration<br />
#<br />
#</code></p>
<p>/etc/my.cnf<br />
innodb_buffer_pool_size = 128M</p>
<p>mysql&gt; SHOW VARIABLES</p>
<pre>+-----------------------------------------+------------------------+
| Variable_name                           | Value                  |
+-----------------------------------------+------------------------+
| innodb_buffer_pool_size                 | 134217728              |
| key_buffer_size                         | 8384512                |
| max_allowed_packet                      | 1048576                |
| sort_buffer_size                        | 2097144                |
| read_buffer_size                        | 131072                 |
| read_rnd_buffer_size                    | 262144                 |
| tmp_table_size                          | 16777216               |
| myisam_sort_buffer_size                 | 8388608                |
| query_cache_size                        | 0                      |
| query_cache_type                        | ON                     |
| query_cache_limit                       | 1048576                |
| thread_cache_size                       | 0                      |
| max_connections                         | 500                    |
| innodb_lock_wait_timeout                | 50                     |
| wait_timeout                            | 28800                  |
+-----------------------------------------+------------------------+
</pre>
<p>./mysqltuner.pl<br />
&#8212;&#8212;&#8211; General Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[--] Skipped version check for MySQLTuner script<br />
[OK] Currently running supported MySQL version 5.1.37<br />
[OK] Operating on 32-bit architecture with less than 2GB RAM</p>
<p>&#8212;&#8212;&#8211; Storage Engine Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster<br />
[--] Data in MyISAM tables: 923M (Tables: 190)<br />
[--] Data in InnoDB tables: 1G (Tables: 549)<br />
[!!] Total fragmented tables: 573</p>
<p>&#8212;&#8212;&#8211; Performance Metrics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Up for: 15s (147 q [9.800 qps], 9 conn, TX: 289K, RX: 75K)<br />
[--] Reads / Writes: 100% / 0%<br />
[--] Total buffers: 154.0M global + 2.7M per thread (500 max threads)<br />
<span style="color: #008000;">[OK] Maximum possible memory usage: 1.5G (73% of installed RAM)<br />
[OK] Slow queries: 0% (0/147)<br />
[OK] Highest usage of available connections: 0% (2/500)<br />
[OK] Key buffer size / total MyISAM indexes: 8.0M/193.3M<br />
[OK] Key buffer hit rate: 100.0% (52 cached / 0 reads)</span><br />
<span style="color: #008000;"><span style="color: #ff0000;">[!!] Query cache is disabled</span><br />
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 71 sorts)<br />
[OK] Temporary tables created on disk: 1% (1 on disk / 70 total)<br />
<span style="color: #ff0000;">[!!] Thread cache is disabled</span><br />
[OK] Table cache hit rate: 88% (55 open / 62 opened)<br />
[OK] Open file limit used: 0% (16/2K)<br />
[OK] Table locks acquired immediately: 100% (366 immediate / 366 locks)<br />
<span style="color: #ff0000;">[!!] Connections aborted: 11%<br />
[!!] InnoDB data size / buffer pool: 1.4G/128.0M</span></span></p>
<p>&#8212;&#8212;&#8211; Recommendations &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
General recommendations:<br />
Run OPTIMIZE TABLE to defragment tables for better performance<br />
MySQL started within last 24 hours &#8211; recommendations may be inaccurate<br />
Enable the slow query log to troubleshoot bad queries<br />
Set thread_cache_size to 4 as a starting value<br />
Your applications are not closing MySQL connections properly<br />
Variables to adjust:<br />
query_cache_size (&gt;= 8M)<br />
thread_cache_size (start at 4)<br />
innodb_buffer_pool_size (&gt;= 1G)</p>
<p>#<br />
#<br />
# New Configuration<br />
#<br />
#</p>
<p>/etc/my.cnf<br />
innodb_buffer_pool_size = 384M<br />
key_buffer = 256M<br />
query_cache_size = 1M<br />
query_cache_limit = 128M<br />
thread_cache_size = 8<br />
max_connections = 400<br />
innodb_lock_wait_timeout = 100</p>
<p>mysql&gt; SHOW VARIABLES</p>
<pre>+-----------------------------------------+------------------------+
| Variable_name                           | Value                  |
+-----------------------------------------+------------------------+
| innodb_buffer_pool_size                 | 402653184              |
| key_buffer_size                         | 268435456 			   |
| max_allowed_packet                      | 1048576                |
| sort_buffer_size                        | 2097144                |
| read_buffer_size                        | 131072                 |
| read_rnd_buffer_size                    | 262144                 |
| tmp_table_size                          | 16777216               |
| myisam_sort_buffer_size                 | 8388608                |
| query_cache_size                        | 1048576                |
| query_cache_type                        | ON                     |
| query_cache_limit                       | 134217728              |
| thread_cache_size                       | 8                      |
| max_connections                         | 400                    |
| innodb_lock_wait_timeout                | 100                    |
| wait_timeout                            | 28800                  |
+-----------------------------------------+------------------------+
</pre>
<p>./mysqltuner.pl<br />
&#8212;&#8212;&#8211; General Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[--] Skipped version check for MySQLTuner script<br />
[OK] Currently running supported MySQL version 5.1.37<br />
[OK] Operating on 32-bit architecture with less than 2GB RAM</p>
<p>&#8212;&#8212;&#8211; Storage Engine Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster<br />
[--] Data in MyISAM tables: 926M (Tables: 190)<br />
[--] Data in InnoDB tables: 1G (Tables: 549)<br />
[!!] Total fragmented tables: 572</p>
<p>&#8212;&#8212;&#8211; Performance Metrics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Up for: 13s (141 q [10.846 qps], 11 conn, TX: 396K, RX: 59K)<br />
[--] Reads / Writes: 97% / 3%<br />
[--] Total buffers: 659.0M global + 2.7M per thread (400 max threads)<br />
<span style="color: #008000;">[OK] Maximum possible memory usage: 1.7G (85% of installed RAM)<br />
[OK] Slow queries: 0% (0/141)<br />
[OK] Highest usage of available connections: 1% (4/400)<br />
[OK] Key buffer size / total MyISAM indexes: 256.0M/193.7M<br />
[OK] Key buffer hit rate: 100.0% (52 cached / 0 reads)<br />
[OK] Query cache efficiency: 23.6% (29 cached / 123 selects)<br />
[OK] Query cache prunes per day: 0<br />
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 53 sorts)<br />
[OK] Temporary tables created on disk: 1% (1 on disk / 54 total)<br />
[OK] Thread cache hit rate: 63% (4 created / 11 connections)<br />
[OK] Table cache hit rate: 86% (46 open / 53 opened)<br />
[OK] Open file limit used: 0% (16/2K)<br />
[OK] Table locks acquired immediately: 100% (265 immediate / 265 locks)</span><br />
<span style="color: #ff0000;">[!!] Connections aborted: 9%<br />
[!!] InnoDB data size / buffer pool: 1.4G/384.0M</span></p>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/databases/mysql-settings-for-magento-website/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Handbook</title>
		<link>http://www.unexpectedit.com/databases/mysql-handbook</link>
		<comments>http://www.unexpectedit.com/databases/mysql-handbook#comments</comments>
		<pubDate>Mon, 14 Jun 2010 21:08:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[load data]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://www.unexpectedit.com/?p=137</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: sql; title: ; notranslate">
-- Shell Commands --
-- -----------------------------
-- Shutdown process
mysqladmin -u root -p shutdown
-- Change admin password
mysqladmin -u root -p'oldpassword' password newpass

-- User Commands --
-- -----------------------------
-- Create a user to access from any host to a database
CREATE USER 'user1'@'%' IDENTIFIED BY 'user1';
GRANT ALL PRIVILEGES ON MyDatabase.* TO user1@'%' IDENTIFIED BY 'user1' WITH GRANT OPTION;
SET PASSWORD FOR 'user1'@'%' = PASSWORD('123456');

DROP USER user@'%';
-- Specific host
CREATE USER 'user1'@'192.168.1.155' IDENTIFIED BY 'user1';
GRANT ALL PRIVILEGES ON MyDatabase.* TO user1@'192.168.1.155' IDENTIFIED BY 'user1' WITH GRANT OPTION;
SET PASSWORD FOR 'user1'@'192.168.1.155' = PASSWORD('123456');

SHOW GRANTS FOR 'user1'@'%'

FLUSH PRIVILEGES;

DROP USER user@'192.168.1.155';

-- My Notes --
-- -----------------------------
-- Text Field, instead of varchar
-- for unlimited text field use TEXT var instead of VARCHAR(number)
-- Not recommended for large databases

-- Databases --
-- -----------------------------
-- Rename database
RENAME DATABASE Db_name TO new_db_name;

-- Export Data
-- -----------------------------
-- Dump database
mysqldump -u'user' -p'password' name_database &gt; /var/www/File-$(date +%F_%R).sql

-- Export Rows Into A SQL File
mysqldump --user root -p --databases mydatabase --tables 'mytable' --where 'id != 10' &gt; fileUploads3.sql

--Export Rows Into A CSV File
SELECT *
 INTO OUTFILE '/Users/nacho/file1.csv'
 FROM mytable;
SELECT *
 INTO OUTFILE '/Users/nacho/file2.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '&quot;'
 FROM mytable
 [...];

-- Import Data --
-- -----------------------------
/*
admin1Codes.txt
ES.00	Ceuta
ES.07	Balearic Islands
ES.27	La Rioja
[...]
Relative Path
*/
LOAD DATA LOCAL INFILE './admin1Codes.txt' INTO TABLE admin1Codes (code, name);
-- Absolute Path
LOAD DATA INFILE '/Users/nacho/Documents/admin1Codes.txt' INTO TABLE admin1Codes (code, name); 

-- Run Commands From Shell --
-- -----------------------------
mysql -u'root' -p'root' -e'SHOW DATABASES'

mysql -u'root' -p'root' database &lt; script.sql

-- Supervising server --
-- -----------------------------
-- Check the current query
mysqladmin processlist -u root -p
-- Check every 2 seconds the active queries
watch mysqladmin pr -u root -p
</pre>
<div id="wpcr_respond_1"></div>]]></content:encoded>
			<wfw:commentRss>http://www.unexpectedit.com/databases/mysql-handbook/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

