<?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; MySQL</title>
	<atom:link href="http://andrewbeaton.net/faq/tag/mysql/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, 10 Mar 2010 21:03:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<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 was writing the [...]]]></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>
		<item>
		<title>Backup a MySQL database</title>
		<link>http://andrewbeaton.net/faq/2009/11/27/backup-mysql-database/</link>
		<comments>http://andrewbeaton.net/faq/2009/11/27/backup-mysql-database/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 20:10:24 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://andrewbeaton.net/faq/?p=65</guid>
		<description><![CDATA[I&#8217;ll just quickly cover some options here to backup a MySQL database. 
The first will output all the data and all the databases along with the schema:

mysqldump -u &#60;user&#62; -p -h &#60;hostname&#62; --all-databases &#62; all_databases.sql

The next option will output just the schema for all of the databases:

mysqldump -d -u &#60;user&#62; -p -h &#60;hostname&#62; --all-databases &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll just quickly cover some options here to backup a MySQL database. </p>
<p>The first will output all the data and all the databases along with the schema:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">&lt;</span>user<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">--all-databases</span> <span style="color: #000000; font-weight: bold;">&gt;</span> all_databases.sql</pre></div></div>

<p>The next option will output just the schema for all of the databases:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-d</span> <span style="color: #660033;">-u</span> <span style="color: #000000; font-weight: bold;">&lt;</span>user<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">--all-databases</span> <span style="color: #000000; font-weight: bold;">&gt;</span> all_databases.sql</pre></div></div>

<p>Now we can use the same two methods above but replace &#8211;all-databases with the name of a database to output just one.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewbeaton.net/faq/2009/11/27/backup-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recover MySQL password</title>
		<link>http://andrewbeaton.net/faq/2009/11/13/recover-mysql-password/</link>
		<comments>http://andrewbeaton.net/faq/2009/11/13/recover-mysql-password/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 22:52:07 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[password reset]]></category>

		<guid isPermaLink="false">http://andrewbeaton.com/faq/?p=21</guid>
		<description><![CDATA[You can recover MySQL database server password with following five easy steps.
Here are commands you need to type for each step (login as the root user):

Stop mysql service
Start to MySQL server w/o password:
Connect to mysql server using mysql client:
Setup new MySQL root user password
Stop MySQL Server:
Start MySQL server and test it

Step # 1 : Stop [...]]]></description>
			<content:encoded><![CDATA[<p>You can recover MySQL database server password with following five easy steps.</p>
<p>Here are commands you need to type for each step (login as the root user):</p>
<ol>
<li>Stop mysql service</li>
<li>Start to MySQL server w/o password:</li>
<li>Connect to mysql server using mysql client:</li>
<li>Setup new MySQL root user password</li>
<li>Stop MySQL Server:</li>
<li>Start MySQL server and test it</li>
</ol>
<p><strong>Step # 1 : Stop mysql service</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/mysql stop</span></pre></div></div>

<p><em>Output:</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Stopping MySQL database server: mysqld.</pre></div></div>

<p><strong>Step # 2: Start to MySQL server w/o password:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mysqld_safe --skip-grant-tables &amp;</span></pre></div></div>

<p><em>Output:</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">1058</span>
Starting mysqld daemon with databases from <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql
mysqld_safe<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6025</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: started</pre></div></div>

<p><strong>Step # 3: Connect to mysql server using mysql client:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mysql -u root</span></pre></div></div>

<p><em>Output:</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection <span style="color: #c20cb9; font-weight: bold;">id</span> is <span style="color: #000000;">1</span> to server version: 4.1.15-Debian_1-log
&nbsp;
Type <span style="color: #ff0000;">'help;'</span> or <span style="color: #ff0000;">'\h'</span> <span style="color: #000000; font-weight: bold;">for</span> help. Type <span style="color: #ff0000;">'\c'</span> to <span style="color: #c20cb9; font-weight: bold;">clear</span> the buffer.
&nbsp;
mysql<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p><strong> Step # 4: Setup new MySQL root user password</strong></p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">use</span> mysql<span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">update</span> <span style="color: #000099;">user</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #000099;">password</span><span style="color: #CC0099;">=</span><span style="color: #000099;">PASSWORD</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">&quot;NEW-ROOT-PASSWORD&quot;</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">where</span> <span style="color: #000099;">User</span><span style="color: #CC0099;">=</span><span style="color: #008000;">'root'</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> flush <span style="color: #990099; font-weight: bold;">privileges</span><span style="color: #000033;">;</span>
mysql<span style="color: #CC0099;">&gt;</span> quit</pre></div></div>

<p><strong>Step # 5: Stop MySQL Server:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/mysql stop</span></pre></div></div>

<p><em>Output:</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Stopping MySQL database server: mysqld
STOPPING server from pid <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>mysqld<span style="color: #000000; font-weight: bold;">/</span>mysqld.pid
mysqld_safe<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6186</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: ended
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+  Done                    mysqld_safe <span style="color: #660033;">--skip-grant-tables</span></pre></div></div>

<p><strong>Step # 6: Start MySQL server and test it</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/mysql start</span>
<span style="color: #666666; font-style: italic;"># mysql -u root -p</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://andrewbeaton.net/faq/2009/11/13/recover-mysql-password/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
