<?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>Andrew Beaton :: FAQ &#187; create temporary table</title>
	<atom:link href="http://andrewbeaton.net/faq/tag/create-temporary-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewbeaton.net/faq</link>
	<description>Tips from the world of a software developer</description>
	<lastBuildDate>Wed, 13 Jul 2011 17:03:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Can&#8217;t create table &#8211; errno: 13</title>
		<link>http://andrewbeaton.net/faq/2009/12/30/cant-create-table-errno-13/</link>
		<comments>http://andrewbeaton.net/faq/2009/12/30/cant-create-table-errno-13/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 16:19:22 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[create temporary table]]></category>
		<category><![CDATA[errno: 13]]></category>

		<guid isPermaLink="false">http://andrewbeaton.net/faq/?p=89</guid>
		<description><![CDATA[I came across a problem today when trying to create a temporary table in MySQL. ERROR 1005 &#40;HY000&#41;: Can't create table 'temptable' (errno: 13) The first thing I checked was that the user in question had the Create_tmp_table_priv privilege in the users table, which it did. The next step was to find out where MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a problem today when trying to create a temporary table in MySQL.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">ERROR <span style="color: #008080;">1005</span> <span style="color: #FF00FF;">&#40;</span>HY000<span style="color: #FF00FF;">&#41;</span>: Can<span style="color: #008000;">'t create table '</span><span style="color: #990099; font-weight: bold;">temptable</span><span style="color: #008000;">' (errno: 13)</span></pre></div></div>

<p>The first thing I checked was that the user in question had the <strong>Create_tmp_table_priv</strong> privilege in the users table, which it did.</p>
<p>The next step was to find out where MySQL was writing the temporary tables. </p>
<p>The following command tells us this:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">show</span> variables <span style="color: #CC0099; font-weight: bold;">like</span> <span style="color: #008000;">'<span style="color: #008080; font-weight: bold;">%</span>dir'</span><span style="color: #000033;">;</span>
<span style="color: #CC0099;">+---------------------------+----------------------------+</span>
<span style="color: #CC0099;">|</span> Variable_name             <span style="color: #CC0099;">|</span> <span style="color: #990099; font-weight: bold;">Value</span>                      <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+---------------------------+----------------------------+</span>
<span style="color: #CC0099;">|</span> basedir                   <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>usr<span style="color: #CC0099;">/</span>                      <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> bdb_logdir                <span style="color: #CC0099;">|</span>                            <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> bdb_tmpdir                <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>tmp<span style="color: #CC0099;">/</span>                      <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> character_sets_dir        <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>usr<span style="color: #CC0099;">/</span>share<span style="color: #CC0099;">/</span>mysql<span style="color: #CC0099;">/</span>charsets<span style="color: #CC0099;">/</span> <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> datadir                   <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>var<span style="color: #CC0099;">/</span>lib<span style="color: #CC0099;">/</span>mysql<span style="color: #CC0099;">/</span>            <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> innodb_data_home_dir      <span style="color: #CC0099;">|</span>                            <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> innodb_log_arch_dir       <span style="color: #CC0099;">|</span>                            <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> innodb_log_group_home_dir <span style="color: #CC0099;">|</span> .<span style="color: #CC0099;">/</span>                         <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> slave_load_tmpdir         <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>tmp<span style="color: #CC0099;">/</span>                      <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">|</span> tmpdir                    <span style="color: #CC0099;">|</span> <span style="color: #CC0099;">/</span>tmp<span style="color: #CC0099;">/</span>                      <span style="color: #CC0099;">|</span>
<span style="color: #CC0099;">+---------------------------+----------------------------+</span></pre></div></div>

<p>And from that we see the tmpdir is located in /tmp/.</p>
<p>A quick checked revealed that MySQL could not create files in this directory, no write access, so a simple permissions change and all was well again.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewbeaton.net/faq/2009/12/30/cant-create-table-errno-13/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

