<?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>Jontas &#187; MySQL</title>
	<atom:link href="http://www.f15ijp.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.f15ijp.com</link>
	<description>My digital notepad (notes etc)</description>
	<lastBuildDate>Wed, 28 Dec 2011 18:24:47 +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 execute statements directly from the (linux) console</title>
		<link>http://www.f15ijp.com/2010/08/18/mysql-execute-statements-directly-from-the-bash-consol/</link>
		<comments>http://www.f15ijp.com/2010/08/18/mysql-execute-statements-directly-from-the-bash-consol/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 09:16:06 +0000</pubDate>
		<dc:creator>jontas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[console]]></category>

		<guid isPermaLink="false">http://www.f15ijp.com/?p=579</guid>
		<description><![CDATA[Executing a query quickly from the console is nice to be able to do (without having to enter the MySQL console). This will simply output the result to the console where you are. user@server:~$ mysql -uUSERNAME -p DATABASENAME --execute &#34;REPAIR TABLE position&#34;; Replace USERNAME and DATABASENAME with your vars If you would like the output [...]]]></description>
			<content:encoded><![CDATA[<p>Executing a query quickly from the console is nice to be able to do (without having to enter the MySQL console).</p>
<ul>
<li><strong>This will simply output the result to the console where you are.</strong>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> user<span style="color: #000000; font-weight: bold;">@</span>server:~$ mysql <span style="color: #660033;">-uUSERNAME</span> <span style="color: #660033;">-p</span> DATABASENAME <span style="color: #660033;">--execute</span> <span style="color: #ff0000;">&quot;REPAIR TABLE position&quot;</span>;</pre></div></div>

<p>Replace USERNAME and DATABASENAME with your vars</li>
<li><strong>If you would like the output to a file</strong>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> mysql <span style="color: #660033;">-uUSERNAME</span> <span style="color: #660033;">-p</span> DATABASENAME <span style="color: #660033;">--execute</span> <span style="color: #ff0000;">&quot;SELECT * FROM test&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> test.sql;</pre></div></div>

<p>Replace USERNAME and DATABASENAME with your vars</li>
<li><strong>If you would like the output to be sent as a email</strong>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> mysql <span style="color: #660033;">-uUSERNAME</span> <span style="color: #660033;">-p</span> DATABASENAME <span style="color: #660033;">--execute</span> <span style="color: #ff0000;">&quot;SELECT * FROM test&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">'SUBJECT'</span> example<span style="color: #000000; font-weight: bold;">@</span>mail.com</pre></div></div>

<p>Replace USERNAME, DATABASENAME , SUBJECT and example@mail.com with your vars</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.f15ijp.com/2010/08/18/mysql-execute-statements-directly-from-the-bash-consol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL Creating several UUIDs at one single time</title>
		<link>http://www.f15ijp.com/2010/07/14/mysql-creating-several-uuids-at-one-single-time/</link>
		<comments>http://www.f15ijp.com/2010/07/14/mysql-creating-several-uuids-at-one-single-time/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 06:56:07 +0000</pubDate>
		<dc:creator>jontas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://www.f15ijp.com/?p=543</guid>
		<description><![CDATA[I recently ran into the problem that I had too add two rows to a database that uses a UUID (in this case converted to a binary) as a key. The problem I had was that running two insert statements after each other (just separated by &#8220;;&#8221;) then the same id was generated. A workaround [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into the problem that I had too add two rows to a database that uses a UUID (in this case converted to a binary) as a key.<br />
The problem I had was that running two insert statements after each other (just separated by &#8220;;&#8221;) then the same id was generated.<br />
A workaround I have found is to sleep for a second between the two statements.</p>
<p>Examples (using SELECT instead of INSERT):<br />
Getting the same id twice</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> uuid1<span style="color: #66cc66;">,</span>  UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> uuid2;
<span style="color: #808080; font-style: italic;">-- Shows: &quot;849392548f1311df91b70019dbd264f1&quot;	&quot;849392908f1311df91b70019dbd264f1&quot;</span></pre></div></div>

<p>Adding a sleep to get different ids</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> uuid1<span style="color: #66cc66;">,</span> SLEEP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> uuid2
<span style="color: #808080; font-style: italic;">-- Shows: &quot;3901c1928f1511df91b70019dbd264f1&quot;	&quot;0&quot;	&quot;399a5b148f1511df91b70019dbd264f1&quot;</span></pre></div></div>

<p>And another one using INSERTS</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> testTable <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span>UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
SLEEP<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> testTable <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span>UNHEX<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>UUID<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'-'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.f15ijp.com/2010/07/14/mysql-creating-several-uuids-at-one-single-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL importing a sql file</title>
		<link>http://www.f15ijp.com/2010/06/07/mysql-importing-a-sql-file/</link>
		<comments>http://www.f15ijp.com/2010/06/07/mysql-importing-a-sql-file/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 08:52:27 +0000</pubDate>
		<dc:creator>jontas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://www.f15ijp.com/?p=492</guid>
		<description><![CDATA[To simply import a sql file (and get any results printed to the prompt) mysql -uUSERNAME -p DBNAME &#60; FILENAME The parameters are -u username (note no space between the u and USERNAME) -p password (can be given as the username (without a space between p and PASSWORD; or if omitted mysql will ask for [...]]]></description>
			<content:encoded><![CDATA[<p><strong>To simply import a sql file (and get any results printed to the prompt)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql <span style="color: #66cc66;">-</span>uUSERNAME <span style="color: #66cc66;">-</span>p DBNAME <span style="color: #66cc66;">&lt;</span> FILENAME</pre></div></div>

<p>The parameters are<br />
-u username (note no space between the u and USERNAME)<br />
-p password (can be given as the username (without a space between p and PASSWORD; or if omitted mysql will ask for it)<br />
DBNAME is the name of the database to import to (if the sql file don&#8217;t create a database on it&#8217;s own)<br />
FILENAME is the name of the file to import</p>
<p>Other parameters can be<br />
-h server host (dns name or ip) <em>if -h is omitted then localhost is assumed.</em><br />
-P port number<br />
-f force (will not break on errors)</p>
<p><strong>To import a sql file and then have to output to a file (for instance when running from a crontab)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql <span style="color: #66cc66;">-</span>uUSERNAME <span style="color: #66cc66;">-</span>p DBNAME <span style="color: #66cc66;">&lt;</span> FILENAME <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">OUTFILE</span></pre></div></div>

<p>Works just as the previous import except that any output will be written to OUTFILE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.f15ijp.com/2010/06/07/mysql-importing-a-sql-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysqldump Couldn&#8217;t execute references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)</title>
		<link>http://www.f15ijp.com/2010/02/12/mysqldump-couldnt-execute-references-invalid-tables-or-columns-or-functions-or-definerinvoker-of-view-lack-rights-to-use-them-1356/</link>
		<comments>http://www.f15ijp.com/2010/02/12/mysqldump-couldnt-execute-references-invalid-tables-or-columns-or-functions-or-definerinvoker-of-view-lack-rights-to-use-them-1356/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 12:27:15 +0000</pubDate>
		<dc:creator>jontas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://f15ijp.com/?p=350</guid>
		<description><![CDATA[If you get an error messages like &#8220;mysqldump: Couldn&#8217;t execute &#8216;SHOW FIELDS FROM `store_information`&#8217;: View &#8216;database.viewname&#8217; references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)&#8221; then a number of things might be wrong: The view is &#8220;corrupted&#8221; (this could happen if the table the view is of [...]]]></description>
			<content:encoded><![CDATA[<p>If you get an error messages like &#8220;mysqldump: Couldn&#8217;t execute &#8216;SHOW FIELDS FROM `store_information`&#8217;: View &#8216;database.viewname&#8217; references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)&#8221; then a number of things might be wrong:</p>
<ul>
<li>The view is &#8220;corrupted&#8221; (this could happen if the table the view is of has been updated in a way so that the view is no longer correct &#8211; for instance if the table structure is updated)</li>
<li>The user you are using are lacking permissions (to the view/table (that the view is referencing) )</li>
</ul>
<p>What I usually do when this happens to solve it is to:</p>
<ol>
<li>Verify if the user running the mysqldump has the permissions (or test as root if you can &#8211; as root has more permissions).
<p>If this is the case: update the permissions on the user running the dump &#8211; or change to another user</p>
</li>
<li>Try to find out if the table the view is referencing has been updated (think back what have I done/check with the rest of the team)<br/><br />
Or if you do not wish to/can not do this, check a previous backup up the base table (from when mysqldump worked with the view) and compare the structure with the current structure in the database.
</li>
<p>If this is the case: I just drop the view and recreate the view so that it gets corrected in the underlying db structure and re-run the dump.</p>
</ol>
<p>More info for people using this notebook as a article; here is some manual pages that will help you along if you don&#8217;t know how to alter permissions/create views.<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/adding-users.html">More information about user permissions</a><br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/create-view.html">More information about views</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.f15ijp.com/2010/02/12/mysqldump-couldnt-execute-references-invalid-tables-or-columns-or-functions-or-definerinvoker-of-view-lack-rights-to-use-them-1356/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

