<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Synthesis: New Plugin: MySQL Tasks</title>
    <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>by Scott Becker</description>
    <item>
      <title>New Plugin: MySQL Tasks</title>
      <description>&lt;p&gt;I wrote some convenience rake tasks to automate creation and backup of MySQL databases, and I use it all the time, so I figured I&amp;#8217;d plugin-afy it to make it simple to use in all my projects, and share it with the world as well! Here&amp;#8217;s &lt;a href="http://sbecker.net/shared/plugins/mysql_tasks"&gt;the repository&lt;/a&gt;&lt;/p&gt;


	&lt;h2&gt;MySQL Tasks&lt;/h2&gt;


	&lt;p&gt;Some rake tasks to automate common database tasks (create/destroy &amp;#38; backup/restore).&lt;/p&gt;


	&lt;h3&gt;Install&lt;/h3&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;./script/plugin install http://sbecker.net/shared/plugins/mysql_tasks&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;h3&gt;Components&lt;/h3&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;rake db:mysql:create           # Create database (using database.yml config)
rake db:mysql:destroy          # Destroy database (using database.yml config)
rake db:mysql:backup           # Dump schema and data to an SQL file (/db/backup_YYYY_MM_DD.sql)
rake db:mysql:restore          # Load schema and data from an SQL file (/db/restore.sql)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Specifying &lt;span class="caps"&gt;RAILS&lt;/span&gt;_ENV works if you want to perform operations on test or production databases.&lt;/p&gt;</description>
      <pubDate>Sun, 10 Dec 2006 14:59:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:d7a1899c-2b56-4ce1-9226-fc3cb75dd7db</guid>
      <author>sbecker</author>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks</link>
      <category>Ruby on Rails</category>
      <category>Web Development</category>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Play Blackjack On Line</title>
      <description>&lt;p&gt;Cheers for the tip. Saved me quite a bit of time from reading the mySQL docs.&lt;/p&gt;


	&lt;p&gt;Thanks mate.&lt;/p&gt;</description>
      <pubDate>Tue, 12 Feb 2008 21:13:53 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:68d62dee-9530-4f12-9586-30c522055c14</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7795</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by J4nus</title>
      <description>&lt;p&gt;Nice ! it works ! very usefull.. and should be integrated in Rails in the future ..&lt;/p&gt;</description>
      <pubDate>Sun, 07 Oct 2007 13:14:36 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:aa497c06-c61f-49c3-aed8-db30475e03ba</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7599</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Mark Ipkins</title>
      <description>&lt;p&gt;Hello, i like cars! Want to have some friends!&lt;/p&gt;</description>
      <pubDate>Wed, 12 Sep 2007 05:34:54 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:08b826ce-771d-4fe1-8f10-e77466e4da32</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7568</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Mark Ipkins</title>
      <description>&lt;p&gt;Hello, i like cars! Want to have some friends!&lt;/p&gt;</description>
      <pubDate>Wed, 12 Sep 2007 05:31:57 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:bf04f6e8-5d18-4c20-9251-48b6c75bbd3a</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7567</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Scott Tadman</title>
      <description>&lt;p&gt;This would be handy to include, too:&lt;/p&gt;


	&lt;p&gt;desc &amp;#8220;Open shell to database (using database.yml config)&amp;#8221; 
task :shell =&amp;gt; :environment do
  database, user, password = retrieve_db_info
  mysql_shell(user, password, database)
end&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;...&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;def mysql_shell(username, password, database)
    system(&amp;#8221;/usr/bin/env mysql -u #{username} -p&amp;#8217;#{password}&amp;#8217; #{database}&amp;#8221;)
end&lt;/p&gt;</description>
      <pubDate>Tue, 17 Jul 2007 15:13:59 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:5030fc83-4b29-46f6-bc94-0c1e55c8ac91</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7493</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Jim Nicholson</title>
      <description>&lt;p&gt;I ran into a problem with systems that don&amp;#8217;t have a password for the mysql &amp;#8220;root&amp;#8221; user. I had to change the mysql_execute method as follows:&lt;/p&gt;


&lt;pre&gt;
def mysql_execute(username, password, sql)
    pwd_opt = password.nil? ? '' : "-p#{password}" 
    system("/usr/bin/env mysql -u #{username} #{pwd_opt} --execute=\"#{sql}\"")
end
&lt;/pre&gt;

	&lt;p&gt;This avoids the &amp;#8216;password&amp;#8217; prompt being issued when mysql is invoked.&lt;/p&gt;</description>
      <pubDate>Mon, 26 Feb 2007 18:38:25 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:bbaddc65-31e3-4433-9fb4-cdfb8bba338c</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-7004</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Scott Becker</title>
      <description>&lt;p&gt;Jason &amp;#8211; I&amp;#8217;ve updated it to use your method, /usr/bin/env to properly find mysql&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Yurii &amp;#8211; I tried your patch but for some reason it didn&amp;#8217;t work for me. The command &amp;#8220;env mysql 2&amp;gt;/dev/stdout&amp;#8221; brings my right to the mysql prompt, so it hangs there&amp;#8230; See if the latest version works as-is&amp;#8230; Seems to work fine for me.&lt;/p&gt;</description>
      <pubDate>Tue, 16 Jan 2007 18:05:53 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:dced81a5-de33-4923-b8ab-0fd265ed55c5</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-6981</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Jason Perry</title>
      <description>&lt;p&gt;Maybe use &lt;code&gt;/usr/bin/env&lt;/code&gt; instead for &lt;code&gt;mysql_bin_root = "/usr/bin"&lt;/code&gt;? Heh, I&amp;#8217;ll submit a patch.&lt;/p&gt;</description>
      <pubDate>Wed, 20 Dec 2006 12:39:44 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:020fbbff-f003-4293-a78e-45c10ad27f38</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-6955</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Jason Perry</title>
      <description>&lt;p&gt;Maybe use &lt;code&gt;/usr/bin/env&lt;/code&gt; instead for &lt;code&gt;mysql_bin_root = "/usr/bin"&lt;/code&gt;?&lt;/p&gt;</description>
      <pubDate>Wed, 20 Dec 2006 12:37:41 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:c075c525-e218-42bf-8a9f-8a74a255e41b</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-6954</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Nathan</title>
      <description>&lt;p&gt;Sorry for the double post, nothing seemed to be happening with the AJAX form &amp;#8230; :(&lt;/p&gt;</description>
      <pubDate>Tue, 12 Dec 2006 14:32:53 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:89a847d1-be92-4b1e-a03c-c37ff043c62d</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-6948</link>
    </item>
    <item>
      <title>"New Plugin: MySQL Tasks" by Nathan</title>
      <description>&lt;p&gt;Very nice, this just saved me a 1/2 hour of my life. Thanks!&lt;/p&gt;</description>
      <pubDate>Tue, 12 Dec 2006 14:32:04 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:f0e9d759-1263-470b-b862-b49b10e1a362</guid>
      <link>http://synthesis.sbecker.net/articles/2006/12/10/new-plugin-mysql-tasks#comment-6947</link>
    </item>
  </channel>
</rss>
