<?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>HostingFu &#187; mysql</title>
	<atom:link href="http://hostingfu.com/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://hostingfu.com</link>
	<description>Web Hosting Blog by a Software Developer</description>
	<lastBuildDate>Mon, 19 Jul 2010 09:27:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Media Temple and Its New MySQL Containers</title>
		<link>http://hostingfu.com/article/media-temple-and-its-new-mysql-containers</link>
		<comments>http://hostingfu.com/article/media-temple-and-its-new-mysql-containers#comments</comments>
		<pubDate>Sat, 20 Jan 2007 13:34:29 +0000</pubDate>
		<dc:creator>scotty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mediatemple]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://hostingfu.com/?p=84</guid>
		<description><![CDATA[Media Temple, home of the Grid Server which I wrote about here, has just posted an excellent post on their blog, titled Anatomy of MySQL on the Grid Server. It Acknowledge MySQL issues in the current grid server platform. Talk about their old load balancing system for MySQL, and why it did not work. Discuss [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://hostingfu.com/files/images/mediatemple-logo.png" width="230" height="23" alt="Media Temple" style="float:right;margin:0 0 1ex 1ex"/> <a href="http://www.mediatemple.com/">Media Temple</a>, home of the <a href="http://www.mediatemple.net/webhosting/gs/">Grid Server</a> which I wrote about <a href="http://hostingfu.com/article/media-temples-grid-server">here</a>, has just posted an excellent post on their blog, titled <a href="http://www.mediatemple.net/weblog/2007/01/19/anatomy-of-mysql-on-the-grid/">Anatomy of MySQL on the Grid Server</a>. It</p>
<ol>
<li>Acknowledge MySQL issues in the current grid server platform.</li>
<li>Talk about their old load balancing system for MySQL, and why it did not work.</li>
<li>Discuss their new VPS based MySQL solution that will be switched on in March.</li>
</ol>
<p><span id="more-84"></span></p>
<p>Scaling databases on a shared multi-tenant system has to be one of the most challenging exercise for system administrators, and I am sure the Media Temple would agree. Because of the way web applications are usually written these days, scaling your PHP apps can be trivial. PHP&#8217;s <a href="http://www.zefhemel.com/archives/2004/09/01/the-share-nothing-architecture">share nothing</a> architecture makes scalability native to the language itself, and you can simply add more boxes to take care the load on the web servers.</p>
<p>However, with &#8220;share-nothing&#8221;, the design is that all states are pushed into the database, and the assumption is that database is scalable. <strong>Is the database scalable</strong>? That alone is worth a separate discussion article. To cut the story short, you cannot simply add more hardware to scale up a busy database server. It usually requires the application to optimise the way data are queried. Setting up replication. Distribute heavy queries. Partition the dataset. Rewrite big queries into smaller ones in case of MySQL. Etc etc.</p>
<p>With shared hosting, you&#8217;ll get even more problems. As a web hosting provider you need to optimise your database to cater for your customers who might install random or home-made apps with badly designed queries.</p>
<p>Media Temple&#8217;s old design was pretty interesting &#8212; a load balancer for MySQL database clusters. From the description, it looks like it constantly monitor all MySQL servers in the system, and live-migrate busy databases onto servers that are less loaded. However it does not work as hostile DB users can still bring the entire database server to its knees, where anyone else on the same server will suffer.</p>
<p>Media Temple&#8217;s new approach is even more interesting &#8212; they will put MySQL into &#8220;containers&#8221;, i.e. a VPS-like environment with restricted CPU and RAM. From the description I think the new MySQL container approach will be even easier to manage than the current load balancing cluster approach.</p>
<p>Each account would have its own MySQL server running inside a VPS. Instead of continuously monitoring the load and move the offending DBs around, they can just rely on the virtualisation software to keep each instance in check. A busy user will only crash his own MySQL container and won&#8217;t affect other accounts. Likewise, a light user should always receive guaranteed CPU and IO.</p>
<p>That&#8217;s quite revolutionary for shared hosts. Well done! It also demonstrated a great use case for VPS &#8212; partition otherwise shared resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://hostingfu.com/article/media-temple-and-its-new-mysql-containers/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL upgrade and unicode issues</title>
		<link>http://hostingfu.com/article/mysql-upgrade-and-unicode-issues</link>
		<comments>http://hostingfu.com/article/mysql-upgrade-and-unicode-issues#comments</comments>
		<pubDate>Fri, 12 May 2006 11:33:50 +0000</pubDate>
		<dc:creator>scotty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://hostingfu.com/?p=22</guid>
		<description><![CDATA[A few days ago I upgraded/emerged MySQL installation on my Unixshell Gentoo box from 4.1.14 to 4.1.19. As it emerges, it also replaced the default configuration file and now uses utf8 as the default encoding to database and client libraries. I also re-emerged dev-lang/php-5.1.4, and it turned out all my unicode on PHP sites are [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I upgraded/emerged <a href="http://www.mysql.com/">MySQL</a> installation on my <a href="http://hostingfu.com/vps/unixshell">Unixshell</a> Gentoo box from 4.1.14 to 4.1.19. As it emerges, it also replaced the default configuration file and now uses <b>utf8</b> as the default encoding to database and client libraries. I also re-emerged <code>dev-lang/php-5.1.4</code>, and it turned out <em>all my unicode on PHP sites are broken</em>! PHP pulls junks out from the database and can&#8217;t display them. Meanwhile, anything unicode you put in there becomes a series of question marks ???? in the rendered page.</p>
<p><span id="more-22"></span></p>
<p><b>D&#8217;oh</b></p>
<p>When I looked at the databases and tables, they all had default charset set to <b>latin1</b>, as they were created in MySQL 4.0.x. However I would like them to be <b>ut8</b>. These are the steps I took to fix up my databases.</p>
<ol>
<li>
<p><b>Back up all databases!!!</b> This is very important. Just in case anything goes wrong, at least we can still restore from the database.</p>
<pre class="code">
$ mysqldump --opt --allow-keywords --hex-blob --all-databases -qc &gt; backup.sql
</pre>
<p>Or you can back up on database by database level to make restoring easier.</p>
</li>
<li>
<p><b>Change the charset of your databases to utf8.</b> If your databases were created prior to MySQL 4.1, the character set will be <b>latin1</b>. Use the command line MySQL client, and issue the following command to change charset:</p>
<pre class="code">
mysql&gt; ALTER DATABASE <em>[database name]</em> DEFAULT CHARACTER SET utf8
    -&gt; COLLATE utf8_general_ci;
</pre>
<p>Or use the following shell script to change character set for <b>all databases</b>:</p>
<pre class="code">
for database in `echo 'SHOW DATABASES;' | mysql -s`
do
    echo "ALTER DATABASE \`$database\` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
done | mysql
</pre>
<p>Now all database should have default charset as utf8, but tables and fields are still in latin1 format.</p>
</li>
<li>
<p><b>Dump database in latin1 and restore in utf8.</b> This is the tricker part. As <code>mysqldump</code> is default to utf8, but we want to dump the tables in latin1 because that&#8217;s what the character sets were. You can do this on database by database level.</p>
<pre class="code">
$ mysqldump --opt --allow-keywords --hex-blob \
&gt; --default-character-set=latin1 -qc <em>[database name]</em> &gt; database.sql
</pre>
<p>Now, open <code>database.sql</code> up and changet all tables/fields declaration from latin1 to utf8! A global search and replace might do, or use some sed magic.</p>
<p>After the edited SQL dump has been saved, just reload them back into the database. <b>Update</b>: Added <code>--default-character-set</code> option just in case MySQL client is not in utf8, which is default for Gentoo (but might not be in other distributions).</p>
<pre class="code">
$ mysql --default-character-set=utf8 <em>[database name]</em> &lt; database.sql
</pre>
<p>And now you have a database that should be utf8 everywhere and works with MySQL 4.1.</p>
</li>
</ol>
<p>Hopefully that works for you as well. I am pretty sure that there are easier ways to achieve it, and I would love to know them as well. If it doesn&#8217;t work out right&#8230; Hmm. You still got the backup?!</p>
<p><b>Update 2006-05-25</b>: <a href="http://blog.robin.smidsrod.no/">Robin</a> wrote me his MySQL unicode fixes to his Zope-based application.</p>
<blockquote>
<p>Luckily I found out what the main problem was. Setting &#8220;<code>default-character-set=latin1</code>&#8221; in the [client] section of <code>/etc/mysql/my.cnf</code> made sure all my legacy apps that don&#8217;t support unicode get latin1 data to them. Seems like a lot of PHP applications assume the data stream is in latin1. The <code>default-character-set</code> solution did the trick for b2Evolution, phpBB, Mambo and a lot of other applications. For Zope it wasn&#8217;t that easy, because <a href="http://sourceforge.net/projects/mysql-python">MySQLdb</a> supported unicode and the latest version of <a href="http://www.zope.org/Members/adustman/Products/ZMySQLDA">ZMySQLDA</a> didn&#8217;t. Found a patch for ZMySQLDA in the mailmanager repository on SourceForge that added unicode support to it. After installing that, activating unicode support in all the connections in the Zope admin interface I was back on track.</p>
<p>The good thing is now I can migrate my applications over to Unicode/UTF8 in an orderly fashion as soon as the applications get native support for Unicode directly with MySQL.</p>
</blockquote>
<p>Thanks for the tip, Robin!</p>
]]></content:encoded>
			<wfw:commentRss>http://hostingfu.com/article/mysql-upgrade-and-unicode-issues/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
