<?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>Halfzerocan &#187; MySQL</title>
	<atom:link href="http://www.halfzerocan.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.halfzerocan.com</link>
	<description>Technology</description>
	<lastBuildDate>Tue, 20 Apr 2010 02:44:46 +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>How to move your MySQL database directory to a second Hard Drive</title>
		<link>http://www.halfzerocan.com/howto-move-your-mysql-database-directory-to-a-second-hard-drive/2008/04/28/</link>
		<comments>http://www.halfzerocan.com/howto-move-your-mysql-database-directory-to-a-second-hard-drive/2008/04/28/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 00:32:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.halfzerocan.com/?p=16</guid>
		<description><![CDATA[If you have a dedicated server with a second Hard Drive then you can often achieve better performance (reduce io wait issues) if you move your MySQL databases to the second Hard Drive. This was done on a server with CentOS operating system. Let&#8217;s say your second HDD is mounted as /home2 1. The first [...]<p>a</p>
]]></description>
			<content:encoded><![CDATA[<p>If you have a dedicated server with a second Hard Drive then you can often achieve better performance (reduce io wait issues) if you move your MySQL databases to the second Hard Drive.</p>
<p><span id="more-16"></span></p>
<p>This was done on a server with CentOS operating system. </p>
<p>Let&#8217;s say your second HDD is mounted as /home2</p>
<p>1. The first step is to stop MySQL so that all your data gets copied correctly.</p>
<p>$ /etc/rc.d/init.d/mysql stop</p>
<p>- or -</p>
<p>$ service mysql* stop</p>
<p>2. Create the new database directory in the second HDD and for this let&#8217;s say it&#8217;s named as mysqldata</p>
<p>$ mkdir /home2/mysqldata</p>
<p>3. Copy the database files from the first HDD to the second HDD</p>
<p>$ cp -R /var/lib/mysql/ /home2/mysqldata</p>
<p>4. Set the correct owner and group, permissions of the new database directory on the 2nd HDD</p>
<p>$ chown -R mysql.mysql /home2/mysqldata/</p>
<p>5. Rename your old database directory</p>
<p>$ mv /var/lib/mysql/ /var/lib/mysql_old</p>
<p>6. Create a symbolic link from the old database directory to the new one for any programs that rely on the default location</p>
<p>$ ln -s /home2/mysqldata/ /var/lib/mysql</p>
<p>7. Set the correct owner and group on the symbolic link</p>
<p>$ chown mysql.mysql /var/lib/mysql</p>
<p>8. Edit the configuration file (/etc/my.cnf) to update the changes</p>
<p>Comment out the old settings and add a line for the new one as you can see below</p>
<p>[mysqld]<br />
#datadir=/var/lib/mysql<br />
datadir=/home2/mysqldata<br />
#socket=/var/lib/mysql/mysql.sock<br />
socket=/home2/mysqldata/mysql.sock</p>
<p>#basedir=/var/lib<br />
basedir=/home2</p>
<p>save my.cnf and exit your text editor</p>
<p>Note that for MySQL version 5 you have to remove the line basedir. The basedir line is only for those who are using MySQL version 4.</p>
<p>9. Restart MySQL</p>
<p>$ /etc/rc.d/init.d/mysql start</p>
<p>- or -</p>
<p>$ service mysql* start</p>
<p>10. If MySQL refuses to start look in /var/log/mysqld.log for the reason</p>
<p>a</p>
]]></content:encoded>
			<wfw:commentRss>http://www.halfzerocan.com/howto-move-your-mysql-database-directory-to-a-second-hard-drive/2008/04/28/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
