<?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>42 &#187; MySQL</title>
	<atom:link href="http://www.42.mach7x.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.42.mach7x.com</link>
	<description>Thoughts and tips about programming with Ruby on Rails</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:38:36 +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>converting MySQL sysdate to local timezone</title>
		<link>http://www.42.mach7x.com/2010/10/12/converting-mysql-sysdate-to-local-timezone/</link>
		<comments>http://www.42.mach7x.com/2010/10/12/converting-mysql-sysdate-to-local-timezone/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 13:09:20 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Dreamhost]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[converting dates]]></category>
		<category><![CDATA[convert_tz]]></category>
		<category><![CDATA[local timezone]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=263</guid>
		<description><![CDATA[Problem You are hosting your MySQL server in a shared host which is in a different country from your application&#8217;s local timezone, and you cannot change the MySQL system timezone, but you would like to use sysdate for date comparisons. Solution In your SQL query that you use for comparing with the system date/time, use [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You are hosting your MySQL server in a shared host which is in a different country from your application&#8217;s local timezone, and you cannot change the MySQL system timezone, but you would like to use sysdate for date comparisons.</p>
<p><strong>Solution</strong><br />
In your SQL query that you use for comparing with the system date/time, use the convert_tz function in MySQL, using the appropriate local time zone (ie Europe/London):<br />
<code>convert_tz(sysdate(),'SYSTEM','Europe/London')</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/10/12/converting-mysql-sysdate-to-local-timezone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; Mysql::Error: Got error 28 from storage engine</title>
		<link>http://www.42.mach7x.com/2010/09/24/rails-mysqlerror-got-error-28-from-storage-engine/</link>
		<comments>http://www.42.mach7x.com/2010/09/24/rails-mysqlerror-got-error-28-from-storage-engine/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 13:06:29 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ibdata1]]></category>
		<category><![CDATA[InnoDB]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=244</guid>
		<description><![CDATA[Problem Trying to access your rails application in your development pc, you get the error: Mysql::Error: Got error 28 from storage engine in your console. Solution It turns out that this specific error is a MySQL error, indicating that you have run out of space in the partition that the MySQL server stores its files [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
Trying to access your rails application in your development pc, you get the error:</p>
<p><code>Mysql::Error: Got error 28 from storage engine</code></p>
<p>in your console.</p>
<p><strong>Solution</strong><br />
It turns out that this specific error is a MySQL error, indicating that you have run out of space in the partition that the MySQL server stores its files (/var/lib/mysql).<br />
Looking at the folder there, you can see a very large file called ibdata1.<br />
This file holds all the information about your InnoDB tables and transactions in your MySQL. According to other posts after a Google search, it seems that this file cannot be reduced in size either by removing/truncating your tables or deleting databases that you don&#8217;t need. There are quite a few solutions out there if you really need to keep a backup of your databases, but if you only using your database for development and you DON&#8217;T NEED (!!) your data or tables, you can move this big ibdata1 to another partition for backup and restart your mysql, that will create a new file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/09/24/rails-mysqlerror-got-error-28-from-storage-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails find case sensitive search</title>
		<link>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/</link>
		<comments>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/#comments</comments>
		<pubDate>Mon, 17 May 2010 16:14:48 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[BINARY]]></category>
		<category><![CDATA[Case insensitive]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=200</guid>
		<description><![CDATA[Problem You want to use find in Rails for a case sensitive search. For example in your authentication logic you have something to find the user to login as in: u=User.find_by_login(&#8216;username&#8217;) If you don&#8217;t want to limit the available logins with case insensitive validation in the model, then the above code will not work if [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to use find in Rails for a case sensitive search. For example in your authentication logic you have something to find the user to login as in:<br />
<span class="code">u=User.find_by_login(&#8216;username&#8217;)</span><br />
If you don&#8217;t want to limit the available logins with case insensitive validation in the model, then the above code will not work if you have &#8216;Username&#8217; and &#8216;username&#8217; as available logins, as the find will only return one of them.</p>
<p><strong>Solution</strong><br />
Change the find method to use the BINARY keyword in your database (only used with MySQL), as in the following:<br />
<span class="code">u=User.find(:first, :conditions => ["BINARY login = ?", login])</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/05/17/rails-find-case-sensitive-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing MySQL GUI tools (mysql-query-browser, mysql-administrator) in Mandriva 2010</title>
		<link>http://www.42.mach7x.com/2010/04/14/installing-mysql-gui-tools-mysql-query-browser-mysql-administrator-in-mandriva-2010/</link>
		<comments>http://www.42.mach7x.com/2010/04/14/installing-mysql-gui-tools-mysql-query-browser-mysql-administrator-in-mandriva-2010/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 10:46:00 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Administrator]]></category>
		<category><![CDATA[Query Browser]]></category>
		<category><![CDATA[RPM]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=191</guid>
		<description><![CDATA[Problem You want to install the GUI tools for MySQL in Mandriva 2010 but a quick search in the MySQL website doesn&#8217;t list the Mandriva rpm files. Solution To install the tools in Mandriva 2010 run: sudo urpmi mysql-query-browser mysql-administrator.]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to install the GUI tools for MySQL in Mandriva 2010 but a quick search in the MySQL website doesn&#8217;t list the Mandriva rpm files.</p>
<p><strong>Solution</strong><br />
To install the tools in Mandriva 2010 run:<br />
<span class="code">sudo urpmi mysql-query-browser mysql-administrator</span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/04/14/installing-mysql-gui-tools-mysql-query-browser-mysql-administrator-in-mandriva-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Flexigrid with MySQL field carriage returns</title>
		<link>http://www.42.mach7x.com/2010/01/05/using-flexigrid-with-mysql-field-carriage-returns/</link>
		<comments>http://www.42.mach7x.com/2010/01/05/using-flexigrid-with-mysql-field-carriage-returns/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 14:47:57 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[FlexiGrid]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=154</guid>
		<description><![CDATA[Problem You want to use flexigrid with a MySQL fields that contains carriage returns. As the flexigrid uses json it doesn&#8217;t work with carriage returns, and displays an empty page, instead of an error page. Solution In the page_name.json.erb file in the fields that has carriage returns make sure that you use to_json method as [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to use flexigrid with a MySQL fields that contains carriage returns. As the flexigrid uses json it doesn&#8217;t work with carriage returns, and displays an empty page, instead of an error page.</p>
<p><strong>Solution</strong><br />
In the page_name.json.erb file in the fields that has carriage returns  make sure that you use to_json method as in the example below:</p>
<p><span class="code">&#8216;<%=fg_escape event.comments.to_json -%>&#8216;,</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2010/01/05/using-flexigrid-with-mysql-field-carriage-returns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mandriva &#8211; Rails 2.3.2 &#8211; mysql gem &#8211; &#8216;ERROR:  Error installing mysql&#8217;</title>
		<link>http://www.42.mach7x.com/2009/04/29/mandriva-rails-232-mysql-gem-problem/</link>
		<comments>http://www.42.mach7x.com/2009/04/29/mandriva-rails-232-mysql-gem-problem/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 12:29:32 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Mandriva]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby on rails 2.3.2]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=101</guid>
		<description><![CDATA[Problem You are trying to install the mysql gem in Mandriva, but it fails with error messages: ERROR: Error installing mysql: ERROR: Failed to build gem native extension... checking for mysql_query() in -lmysclient... no .... Solution After searching in google, with solutions about providing different options (&#8211; &#8211;with-mysql-config, ..etc), even trying different combinations for providing [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You are trying to install the mysql gem in Mandriva, but it fails with error messages:</p>
<pre class="code">ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension...
checking for mysql_query() in -lmysclient... no ....</pre>
<p><strong>Solution</strong><br />
After searching in google, with solutions about providing different options (&#8211; &#8211;with-mysql-config, ..etc), even trying different combinations for providing the client library path, the configuration file, or the header file path, was still faced with the same error installing the mysql gem.<br />
As the Mandriva installation was quite new, it turns out to be a couple of missing packages.<br />
So try:</p>
<pre class="code">urpmi gcc
urpmi make</pre>
<p>and run:</p>
<pre class="code">gem install mysql</pre>
<p>again.</p>
<p>It should work out ok install the gem and output:</p>
<pre class="code">Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/04/29/mandriva-rails-232-mysql-gem-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing data from two big MySQL tables</title>
		<link>http://www.42.mach7x.com/2009/02/16/comparing-data-from-two-big-mysql-tables/</link>
		<comments>http://www.42.mach7x.com/2009/02/16/comparing-data-from-two-big-mysql-tables/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 12:44:40 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[export]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=90</guid>
		<description><![CDATA[Problem You have two big tables in MySQL (>640K records), that maybe differ in the number of fields, but you want to make sure that the data in the common fields in both tables are the same. Solution Use mysql to export the data from the first table in a csv file, selecting only the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You have two big tables in MySQL (>640K records), that maybe differ in the number of fields, but you want to make sure that the data in the common fields in both tables are the same.</p>
<p><strong>Solution</strong></p>
<ol>
<li>Use mysql to export the data from the first table in a csv file, selecting only the common fields.<br />
We use the /tmp folder on the server to make sure we have the right permissions to create the file:</p>
<pre class="code">mysql>SELECT common_field1, common_field2, ...
INTO OUTFILE '/tmp/first_table.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table1;</pre>
</li>
<li><i>If the tables are in different databases remember to switch db:</i>
<pre class="code">use seconddb;</pre>
<p>Export the second table in the second file:</p>
<pre class="code">mysql>SELECT common_field1, common_field2, ...
INTO OUTFILE '/tmp/second_table.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table2;</pre>
</li>
<li>now use the diff. You can use any of the following options:
<ul>
<li>diff -q first_table.txt second_table.txt</li>
<li>diff first_table.txt second_table.txt > diff.txt</li>
</ul>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/02/16/comparing-data-from-two-big-mysql-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Paradox tables to MySQL sql in Linux</title>
		<link>http://www.42.mach7x.com/2008/04/21/converting-paradox-tables-to-mysql-in-linux/</link>
		<comments>http://www.42.mach7x.com/2008/04/21/converting-paradox-tables-to-mysql-in-linux/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 13:11:07 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[exporting]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[paradox]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=28</guid>
		<description><![CDATA[Problem You want to convert some legacy tables created in Paradox (.db, .px) to another format so you can use it in MySQL. Solution Download the px tools from here. Follow the instructions, in the INSTALL file after you untar the file. You should have to do the usual three step linux installation: configure make [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to convert some legacy tables created in Paradox (.db, .px) to another format so you can use it in MySQL.</p>
<p><strong>Solution</strong><br />
Download the px tools from <a href="http://jan.kneschke.de/projects/pxtools/">here</a>.</p>
<p>Follow the instructions, in the INSTALL file after you untar the file.<br />
You should have to do the usual three step linux installation:</p>
<pre class="code">configure
make
sudo make install</pre>
<p>Afterwards to make sure that the .db file is a paradox file run:</p>
<pre class="code">pxinfo -f  path/to/paradox/db/file.db</pre>
<p>The program should read the header and report back with something along the lines:</p>
<pre class="code">File-Version: Paradox 7.x
Filetype: indexed .DB
....</pre>
<p>To export each Paradox db file to an sql statement run the following:</p>
<pre class="code">pxsqldump -d mysql -f path/to/paradox/file.db > path/to/mysql/exported/file.sql</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2008/04/21/converting-paradox-tables-to-mysql-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>File column plugin with ActiveScaffold upload branch</title>
		<link>http://www.42.mach7x.com/2007/10/17/file-column-plugin-with-activescaffold-upload-branch/</link>
		<comments>http://www.42.mach7x.com/2007/10/17/file-column-plugin-with-activescaffold-upload-branch/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 15:29:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=4</guid>
		<description><![CDATA[When using the file_column plugin in the active_scaffold upload branch, the documentation in the file_column doesn&#8217;t make it clear what we have to change to make it work. In the example below the model is number and the file_column is intro. 1. In models/number.rb add: file_column :intro 2. in controllers/numbers_controller.rb, make sure we have: config.create.multipart [...]]]></description>
			<content:encoded><![CDATA[<p>When using the file_column plugin in the active_scaffold upload branch, the documentation in the file_column doesn&#8217;t make it clear what we have to change to make it work.</p>
<p>In the example below the model is number and the file_column is intro.</p>
<p>1. In models/number.rb add:</p>
<pre class="code">file_column :intro</pre>
<p>2. in controllers/numbers_controller.rb, make sure we have:</p>
<pre class="code">config.create.multipart = true
config.update.multipart = true</pre>
<p>3. in helpers/numbers_helper.rb add:</p>
<pre class="code">def intro_form_column(record, input name)
  file_column_field 'record', :intro
end

def intro_column(record)
  record.intro ? link_to(File.basename(record.intro),
    url_for_file_column(record,'intro'), :popup =&gt; true) : "-"
end</pre>
<p>4. in views/numbers/_intro_form_column.rhtml add:</p>
<pre class="code"><label>  File to upload</label>
  &lt;%= file_column_field  'record', 'intro' %&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2007/10/17/file-column-plugin-with-activescaffold-upload-branch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get a random record in Ruby on Rails &#8211; MySQL</title>
		<link>http://www.42.mach7x.com/2007/10/17/hello-world/</link>
		<comments>http://www.42.mach7x.com/2007/10/17/hello-world/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 14:22:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[web programming]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=1</guid>
		<description><![CDATA[To get a random record from MySQL in Ruby on Rails use: User.find(:all, rder =&#62; 'rand()')]]></description>
			<content:encoded><![CDATA[<p>To get a random record from MySQL in Ruby on Rails use:</p>
<pre class="code">User.find(:all, <img src='http://www.42.mach7x.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&gt; 'rand()')</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2007/10/17/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

