<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>Tildemark blogs</title>
        <link>http://www.tildemark.com/</link>
        <description>Blogging on uniquely random things. </description>
        <language>en</language>
        <copyright>Copyright 2008</copyright>
        <lastBuildDate>Thu, 08 Feb 2007 10:51:43 +0800</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>Inserting duplicate indexed field in mysql</title>
            <description><![CDATA[<p>#1062 - Duplicate entry indexed_field' for key 2</p>

<p>Mysql will return a duplicate entry error when trying to insert a duplicate value in an indexed field in the database. We could modify our sql insert state to check for primary key duplicate or index field duplicate and automatically update the first field with the updated value like this.</p>

<p><code><br />
INSERT&nbsp;INTO table1 (a,b,c) <br />
SELECT a,b,c <br />
FROM table2<br />
WHERE a IS NOT NULL<br />
ON DUPLICATE KEY <br />
UPDATE table1.a = table2.a<br />
</code></p>]]></description>
            <link>http://www.tildemark.com/programming/mysql/inserting-duplicate-indexed-field-in-mysql.html</link>
            <guid>http://www.tildemark.com/programming/mysql/inserting-duplicate-indexed-field-in-mysql.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">MySQL</category>
            
            
            <pubDate>Thu, 08 Feb 2007 10:51:43 +0800</pubDate>
        </item>
        
        <item>
            <title>Mysqldump memory loss</title>
            <description><![CDATA[<p><b>mysqldump </b> - i often use these to copy tables from one server to another since i find the phpmyadmin dump to be very slow and sometimes i get a page timeout. aside from copying a database to another you can also use it to backup your database or all of your databases. a mysql dump file contains sql statements to create databases, populate tables, or populate rows. Most of the time i saved the dump file as a .sql but you could also specify to save it as a .csv or perhaps .xml etc. </p>

<p>When restoring it i use the command \. on the mysql command prompt, i find it much easier that way than typing it on the shell. </p>

<p>i keep on forgetting the syntax to these commands so i better jot them down. These are syntax from the manual and is the most common syntax used in creating a mysql database dump.<br />
<div class="module-code"></p>

<p>shell> mysqldump [options] db_name [tables]<br />
shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...]<br />
shell> mysqldump [options] --all-databases<br />
</div></p>

<p>example in backing up the mysql database: <br />
<div class="module-code"></p>

<p>shell> mysqldump db_name > [backup-file.sql]<br />
</div></p>

<p>dump all databases:<br />
<div class="module-code"></p>

<p>shell> mysqldump --all-databases > all_databases.sql<br />
</div></p>

<p>and restoring it back: <br />
<div class="module-code"></p>

<p>shell> mysql db_name < backup-file.sql<br />
</div></p>

<p>this is what I use: <br />
<div class="module-code"></p>

<p>mysqldump -u [user] -p[pass] [dbname] > [filename.sql]<br />
</div></p>

<p>add it in cron:<br />
<div class="module-code"></p>

<p>#!/bin/sh<br />
date=`date -I`<br />
mysqldump --opt --all-databases | bzip2 -c > /var/backup/backup-$date.sql.bz2<br />
</div></p>]]></description>
            <link>http://www.tildemark.com/programming/mysql/mysqldump-memory-loss.html</link>
            <guid>http://www.tildemark.com/programming/mysql/mysqldump-memory-loss.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">MySQL</category>
            
            
            <pubDate>Thu, 25 Jan 2007 10:15:27 +0800</pubDate>
        </item>
        
        <item>
            <title>Cannot Load Mysql extension please check PHP configuration in phpMyAdmin</title>
            <description><![CDATA[<p>I often get this error when i'm installing mysql server and running phpmyadmin. Just in case you are also experiencing the same, </p>

<p>Find your php.ini file. Open your httpd.conf file and look for the PHPIniDir variable. If it is set to C:\PHP then use that ini file. </p>

<p>Open your php.ini file on your php folder usually at C:\PHP. Look for this line <br />
<div class="module-code"><br />
;extension=php_mysql.dll<br />
</div><br />
uncomment the line by removing the semicolon ';'</p>

<p>Look for the loadable extension modules directory called extension_dir, set it to <br />
<div class="module-code"><br />
extension_dir = "c:\php\ext"<br />
</div></p>

<p>You might want to enable mbstring and curl modules as well by uncommenting the following lines on your php.ini file.</p>

<div class="module-code">
extension=php_mbstring.dll
extension=php_curl.dll
</div>]]></description>
            <link>http://www.tildemark.com/programming/mysql/cannot-load-mysql-extension-please-check-php-confi.html</link>
            <guid>http://www.tildemark.com/programming/mysql/cannot-load-mysql-extension-please-check-php-confi.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">MySQL</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">PHP</category>
            
            
            <pubDate>Mon, 02 Oct 2006 07:12:49 +0800</pubDate>
        </item>
        
        <item>
            <title>Random MySQL Results</title>
            <description><![CDATA[<p>I never knew there was a built-in random function in MySQL. What i did was get all the rows and using PHP's array_rand to get a random set of rows. When using RAND() in MySQL together with the LIMIT keywords it returns only the number of rows required for a random. It really saved so many lines of my code.</p>

<p>We can get a random number from the MySQL server using:<br />
<code>mysql> SELECT RAND();<br />
</code></p>

<p>We can also add a seed value by adding an argument to our RAND function:<br />
<code>mysql> SELECT RAND(34);<br />
</code></p>

<p>To retrive rows in random we use:<br />
<code>mysql> SELECT * FROM tbl_name ORDER BY RAND();<br />
</code></p>

<p>Now with the LIMIT keyword added:<br />
<code>mysql> SELECT * FROM tbl_name ORDER BY RAND() LIMIT 1000;<br />
</code></p>]]></description>
            <link>http://www.tildemark.com/programming/mysql/random-mysql-results.html</link>
            <guid>http://www.tildemark.com/programming/mysql/random-mysql-results.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">MySQL</category>
            
            
            <pubDate>Tue, 29 Aug 2006 16:02:03 +0800</pubDate>
        </item>
        
    </channel>
</rss>






