<?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>wanna-be-a-Debian-system-administrator &#187; database</title>
	<atom:link href="http://debian.kitaj.net/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://debian.kitaj.net</link>
	<description></description>
	<lastBuildDate>Wed, 31 Aug 2011 15:03:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Finding duplicate entries in MySQL database</title>
		<link>http://debian.kitaj.net/2011/07/finding-duplicate-entries-in-mysql-database/</link>
		<comments>http://debian.kitaj.net/2011/07/finding-duplicate-entries-in-mysql-database/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 10:04:17 +0000</pubDate>
		<dc:creator>mitja</dc:creator>
				<category><![CDATA[Moodle]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://debian.kitaj.net/?p=89</guid>
		<description><![CDATA[On upgrading my Moodle installation from version 1.9 to 2.1 the upgrade process (initiated from command line) exited with the following error: !!! Error reading from database !!! !! Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=' SELECT po.id AS oldpage_id, po.pagename AS oldpage_pagename, po.version, po.flags, po.content, po.author, po.userid AS oldpage_userid, po.created, po.lastmodified, [...]]]></description>
			<content:encoded><![CDATA[<p>On upgrading my Moodle installation from version 1.9 to 2.1 the upgrade process (initiated from command line) exited with the following error:</p>
<pre>
!!! Error reading from database !!!
!! Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
SELECT po.id AS oldpage_id, po.pagename AS oldpage_pagename, po.version, po.flags,
                   po.content, po.author, po.userid AS oldpage_userid, po.created, po.lastmodified, po.refs, po.meta, po.hits, po.wiki,
                   p.id AS newpage_id, p.subwikiid, p.title, p.cachedcontent, p.timecreated, p.timemodified AS newpage_timemodified,
                   p.timerendered, p.userid AS newpage_userid, p.pageviews, p.readonly, e.id AS entry_id, e.wikiid, e.course AS entrycourse,
                   e.groupid, e.userid AS entry_userid, e.pagename AS entry_pagename, e.timemodified AS entry_timemodified,
                   w.id AS wiki_id, w.course AS wiki_course, w.name, w.summary AS summary, w.pagename AS wiki_pagename, w.wtype,
                   w.ewikiprinttitle, w.htmlmode, w.ewikiacceptbinary, w.disablecamelcase, w.setpageflags, w.strippages, w.removepages,
                   w.revertchanges, w.initialcontent, w.timemodified AS wiki_timemodified,
                   cm.id AS cmid
              FROM wiki_pages_old po
              LEFT OUTER JOIN wiki_entries_old e ON e.id = po.wiki
              LEFT OUTER JOIN wiki w ON w.id = e.wikiid
              LEFT OUTER JOIN wiki_subwikis s ON e.groupid = s.groupid AND e.wikiid = s.wikiid AND e.userid = s.userid
              LEFT OUTER JOIN wiki_pages p ON po.pagename = p.title AND p.subwikiid = s.id
              JOIN modules m ON m.name = 'wiki'
              JOIN course_modules cm ON (cm.module = m.id AND cm.instance = w.id)
</pre>
<p>Summed up — an &#8220;Illegal mix of collations&#8221; was occurring while querying the table <em>wiki_pages_old</em>. A quick search found a <a href="http://moodle.org/mod/forum/discuss.php?d=167193" target="_blank">possible solution</a>. Unfortunately (for now) I&#8217;m not really sure if it helped, since the error persisted, but it is worth of making a note of it until being sure (by migrating the production server).</p>
<p>So I went in with phpMyAdmin and changed the collation on the table manually, which didn&#8217;t help either, since it didn&#8217;t change the collation of the individual fields. So I changed the fields&#8217; collation manually, except for one field, which — after changing the collation — started to report a duplicate entry. After some trial and error I&#8217;ve found a solution.</p>
<p>From the table dump file I&#8217;ve deleted the offending key and after importing the table into the database I&#8217;ve searched for the offending duplicate entries.</p>
<p>The following MySQL query, from <a href="http://forums.mysql.com/read.php?10,180556,180572#msg-180572">MySQL forum</a>, finds the duplicate entries.</p>
<p><code>SELECT t1.* FROM t1 INNER JOIN (<br />
SELECT colA,colB,COUNT(*) FROM t1 GROUP BY colA,colB HAVING COUNT(*)>1) as t2<br />
ON t1.cola = t2.cola and t1.colb = t2.colb;</code></p>
<p>In my case the upper query changes into this:</p>
<p><code>SELECT wiki_pages_old.* FROM wiki_pages_old INNER JOIN (<br />
SELECT pagename,version,wiki,COUNT(*) FROM wiki_pages_old GROUP BY pagename,version,wiki HAVING COUNT(*)>1) as wiki_t2<br />
ON wiki_pages_old.pagename = wiki_t2.pagename and wiki_pages_old.version = wiki_t2.version and wiki_pages_old.wiki = wiki_t2.wiki;</code></p>
<p>I&#8217;ll write some more details after migrating the production server.</p>
]]></content:encoded>
			<wfw:commentRss>http://debian.kitaj.net/2011/07/finding-duplicate-entries-in-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How-to change existing record in MySQL database</title>
		<link>http://debian.kitaj.net/2007/03/how-to-change-existing-record-in-mysql-database/</link>
		<comments>http://debian.kitaj.net/2007/03/how-to-change-existing-record-in-mysql-database/#comments</comments>
		<pubDate>Sun, 25 Mar 2007 02:03:39 +0000</pubDate>
		<dc:creator>Mitja</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[password]]></category>

		<guid isPermaLink="false">http://debian.kitaj.net/index.php/2007/03/how-to-change-existing-record-in-mysql-database/</guid>
		<description><![CDATA[Sometimes I forget some password for accessing CMS system and mail is not working and &#8230; So far it never happened that  I forgot some more important password, such as MySQL access password in which case I can change password directly in the database and thus enable myself to access the CMS backend The &#8220;magic&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I forget some password for accessing CMS system and mail is not working and &#8230;</p>
<p>So far it never happened that  I forgot some more important password, such as MySQL access password in which case I can change password directly in the database and thus enable myself to access the CMS backend</p>
<p>The &#8220;magic&#8221; line is</p>
<blockquote><p>UPDATE table_name SET column_to_change WHERE record_to_update;</p></blockquote>
<p>To be less general and less abstract: in case of password change the line should look like this:</p>
<blockquote><p>UPDATE table_name SET password_column = MD5(&#8216;new_password&#8217;) WHERE ID = user_id_to_change;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://debian.kitaj.net/2007/03/how-to-change-existing-record-in-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to query MSSQL database with Debian GNU/Linux (Sarge)</title>
		<link>http://debian.kitaj.net/2006/09/how-to-query-mssql-database-with-debian-gnulinux-sarge/</link>
		<comments>http://debian.kitaj.net/2006/09/how-to-query-mssql-database-with-debian-gnulinux-sarge/#comments</comments>
		<pubDate>Thu, 21 Sep 2006 20:09:59 +0000</pubDate>
		<dc:creator>Mitja</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://debian.kitaj.net/index.php/2006/09/how-to-query-mssql-database-with-debian-gnulinux-sarge/</guid>
		<description><![CDATA[Every now and then you have to do unpleasant things and so one day I was faced with data hidden in MSSQL database. Searching internet I was not able to find a solution so I asked for help on Debian User mailing list and got this reply. Following the suggestions I managed to get what [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then you have to do unpleasant things and so one day I was faced with data hidden in MSSQL database. Searching internet I was not able to find a solution so I asked for help on Debian User mailing list and got <a title="Link to post." target="_blank" href="http://lists.debian.org/debian-user/2006/09/msg01766.html">this reply</a>.<br />
Following the suggestions I managed to get what I needed and here it is the whole process.</p>
<p><span id="more-5"></span></p>
<p>First install <em>unixodbc</em> package<br />
<code>apt-get install unixodbc</code><br />
If you want GUI then also install <em>unixodbc-bin</em></p>
<p>Next install <em /> package<br />
<code>apt-get install freetds-dev</code><br />
the <em>freetds-dev</em> package has two dependencies which will be also installed</p>
<p>During the <em>freetds-dev</em> package instalation you will be asked if you want the <em>FreeTDS ODBC Driver</em> to be registered automaticaly with <em>unixODBC</em>. If you say no, you will have to do it manualy afterwards.</p>
<p>After this follow the manuals on <a class="LinkVTekstu" href="http://www.unixodbc.org/">unixodbc.org</a> to configure the whole thing.</p>
<p>If you followed the above steps you can skip directly to chapter &#8220;Creating an ODBC Data Source Name&#8221; of the <a class="LinkVTekstu" href="http://www.unixodbc.org/doc/FreeTDS.html">How to use unixODBC with FreeTDS</a> manual and configure <em>ODBC Data Source Name</em>.</p>
<p>To make your steps around ODBC GUI easyer read the <a class="LinkVTekstu" href="http://www.unixodbc.org/doc/UserManual/">User Manual </a></p>
<p><small>Installation occured on 21.9.2006<br />
this document was last changed on 21.9.2006</small></p>
]]></content:encoded>
			<wfw:commentRss>http://debian.kitaj.net/2006/09/how-to-query-mssql-database-with-debian-gnulinux-sarge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

