<?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>Avivo Tech Blog &#187; database</title>
	<atom:link href="http://tech.avivo.si/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Adding stored JavaScript procedures to MongoDB using Windows Batch script</title>
		<link>http://tech.avivo.si/2011/10/adding-stored-javascript-procedures-to-mongodb-using-windows-batch-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adding-stored-javascript-procedures-to-mongodb-using-windows-batch-script</link>
		<comments>http://tech.avivo.si/2011/10/adding-stored-javascript-procedures-to-mongodb-using-windows-batch-script/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 12:05:55 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System administration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mongo]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Stored Procedure]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1394</guid>
		<description><![CDATA[MongoDB can use stored procedures similar to MSSQL. To make a MongoDB procedure create a new file, name it like DoSomething.js, write a function and attach it to database. Guide through example Lets say we have a log of website visitors stored in visitors collection inside myweb database. Each visitors record contains date and time [...]]]></description>
			<content:encoded><![CDATA[<p>MongoDB can use stored procedures similar to MSSQL. To make a MongoDB procedure create a new file, name it like <strong>DoSomething.js</strong>, write a function and attach it to database.</p>
<h2>Guide through example</h2>
<p>Lets say we have a log of website visitors stored in <strong>visitors</strong> collection inside <strong>myweb</strong> database. Each <strong>visitors</strong> record contains date and time of a visit. Now we want to create monthly statistics &#8211; how many users visits website per month.</p>
<p><strong>visitors</strong> collection looks like:</p>
<pre>&gt; use myweb
&gt; db.visitors.findOne()
{
  "_id": ObjectId("4e0cb7e7da3ea11d18d841e7"),
  "timestamp": "Thu Jun 30 2011 19:52:39 GMT+0200 (Central Europe Daylight Time)"
}</pre>
<p>Most reusable way to get data is to create a stored procedure <strong>GetVisitsPerMonth()</strong> and call it on demand. Create a file <strong>GetVisitsPerMonth.js</strong> and copy-paste the following code inside. Note that file name is named by procedure.</p>
<pre>function ()
{
	var result = db.visitors.group(
	{
		keyf: function(doc)
		{
			return { //NOTE: Bracket must be in this line!!!
				month: doc.timestamp.getMonth(),
				year: doc.timestamp.getFullYear()
			};
		},
		initial: {count:0},
		reduce: function(doc, prev) { prev.count++ }
	});

	return result;
}</pre>
<h2>How to attach one procedure</h2>
<p>Stored procedure can be manually attached like this:</p>
<pre>db = connect("localhost:27017/myweb");
db.system.js.save({"_id":"GetVisitsPerMonth", "value": function() { ... });</pre>
<h2>How to attach multiple procedures</h2>
<p>Large sets of procedures should be well organized in files so you can quickly find a procedure and fix it if necessary. To insert or update all procedures at once use a simple batch script.</p>
<p>Create a new file, name it <strong>install.bat</strong> and copy-paste the following code inside:</p>
<pre>@echo off

:parameters
set DBCON=localhost:27017/myweb
set MONGO=c:\mongodb\bin\mongo.exe
set SCRIPT=script.js

:startup
if not exist %MONGO% goto error
if not "%1"=="" goto add

rem Append connection string
echo Adding connection string...
echo db = connect("%DBCON%"); &gt; %SCRIPT%
echo. &gt;&gt; %SCRIPT%

rem Append scripts
call %0 GetVisitsPerMonth
rem call %0 DoSomething
rem other procedures go here

goto install
rem goto end

:add
echo Adding script %1...
echo db.system.js.save({"_id":"%1", "value": &gt;&gt; %SCRIPT%
type %1.js &gt;&gt; %SCRIPT%
echo }); &gt;&gt; %SCRIPT%
echo. &gt;&gt; %SCRIPT%
goto end

:install
echo Running script...
%MONGO% %SCRIPT%
goto end

:error
echo Check if mongo is installed:
echo %MONGO%

:end</pre>
<p>Edit parameters according to your needs: path to mongo.exe, database name, and list of procedures.<br />
Simply run the script and it is done.</p>
<h2>Testing a stored procedure</h2>
<p>Log into mongo console:</p>
<pre>&gt; use myweb
&gt; db.eval("GetVisitsPerMonth()")
[
  {
    "month": 5,
    "year": 2011,
    "count": 28233,
  },
  {
    "month": 6,
    "year": 2011,
    "count": 48026,
  },
  {
    "month": 7,
    "year": 2011,
    "count": 92754,
  }
]</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/10/adding-stored-javascript-procedures-to-mongodb-using-windows-batch-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ Max and Min functions upgraded</title>
		<link>http://tech.avivo.si/2011/04/linq-max-and-min-functions-upgraded/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linq-max-and-min-functions-upgraded</link>
		<comments>http://tech.avivo.si/2011/04/linq-max-and-min-functions-upgraded/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 09:00:06 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datacontext]]></category>
		<category><![CDATA[first]]></category>
		<category><![CDATA[firstordefault]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[linq min function throws an exception]]></category>
		<category><![CDATA[max]]></category>
		<category><![CDATA[min]]></category>
		<category><![CDATA[min linq function throws an exception]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1266</guid>
		<description><![CDATA[Classic LINQ Max and Min functions have the same problem as First function &#8211; exception can occur, so we use FirstOrDefault which returns null instead of exception. So, this is how you can extend Min and Max functions into MinOrDefault and MaxOrDefault; public static class IEnumerableExtensions { public static int MinOrDefault(this IEnumerable source, Func selector, [...]]]></description>
			<content:encoded><![CDATA[<p>Classic LINQ <strong>Max </strong>and <strong>Min </strong>functions have the same problem as <strong>First </strong>function &#8211; exception can occur, so we use <strong>FirstOrDefault </strong>which returns <strong>null </strong>instead of exception.</p>
<p>So, this is how you can extend <strong>Min </strong>and <strong>Max </strong>functions into <strong>MinOrDefault </strong>and <strong>MaxOrDefault</strong>;</p>
<pre class="csharp">
public static class IEnumerableExtensions
{
  public static int MinOrDefault<TSource>(this IEnumerable<TSource> source,
    Func<TSource, int> selector, int defaultValue)
  {
    if (source.Any<TSource>())
      return source.Min<TSource>(selector);

    return defaultValue;
  }

  public static int MaxOrDefault<TSource>(this IEnumerable<TSource> source,
    Func<TSource, int> selector, int defaultValue)
  {
    if (source.Any<TSource>())
      return source.Max<TSource>(selector);

    return defaultValue;
  }
}
</pre>
<p>&nbsp;</p>
<p><strong>Usage example:</strong></p>
<pre class="csharp">
  YourDataContext db = new YourDataContext();
  int maxVisits = db.SomeEntityTables.MaxOrDefault(x => x.SomeFieldYouSearchForMaximum, 0);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/04/linq-max-and-min-functions-upgraded/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to clear recent servers list in MS SQL 2005 Management Studio?</title>
		<link>http://tech.avivo.si/2010/08/how-to-clear-recent-servers-list-in-ms-sql-2005-management-studio/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-clear-recent-servers-list-in-ms-sql-2005-management-studio</link>
		<comments>http://tech.avivo.si/2010/08/how-to-clear-recent-servers-list-in-ms-sql-2005-management-studio/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 21:19:40 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[clear recent ms sql servers list in server name drop down list]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[ms sql server 2005]]></category>
		<category><![CDATA[smss]]></category>
		<category><![CDATA[sql server management studio]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=559</guid>
		<description><![CDATA[So, you have Microsoft SQL Server 2005 Management Studio (SSMS) and when trying to connect &#8220;Server name&#8221; drop down list is filled with sensitive data: To clear this list, all you have to do is delete this file: C:\Documents and Settings\&#60;user&#62;\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat. Just remember, once you delete that file all of your previous [...]]]></description>
			<content:encoded><![CDATA[<p>So, you have Microsoft SQL Server 2005 Management Studio (SSMS) and when trying to connect &#8220;Server name&#8221; drop down list is filled with sensitive data:<br />
<img class="alignnone size-full wp-image-560" title="sql-server-recent-list" src="http://tech.avivo.si/wp-content/uploads/2010/08/sql-server-recent-list.jpg" alt="" width="640" height="441" /></p>
<p>To clear this list, all you have to do is delete this file:<br />
C:\Documents and Settings\&lt;user&gt;\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat.</p>
<p>Just remember, once you delete that file all of your previous connections will be lost. So make sure that you have any necessary IP addresses, usernames, and passwords that you&#8217;ll need to reconnect to your favorite/most used SQL Servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/08/how-to-clear-recent-servers-list-in-ms-sql-2005-management-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Linq to SQL classes from .sdf (Local database)</title>
		<link>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-linq-to-sql-classes-from-sdf-local-database</link>
		<comments>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 18:53:00 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[code generator]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[sdf]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=462</guid>
		<description><![CDATA[Linq allows to handle data easily. Linq to SQL tools are integrated in Visual Studio but is limited to can generate code only for  certain databases. To create ORM from .sdf database file read on&#8230; What to do? Copy next script to a file with .bat extension. Change DATABASE_NAME, DATABASE_PASSWORD and NAMESPACE according to your [...]]]></description>
			<content:encoded><![CDATA[<p>Linq allows to handle data easily. Linq to SQL tools are integrated in Visual Studio but is limited to can generate code only for  certain databases. To create ORM from .sdf database file read on&#8230;</p>
<p><strong>What to do?</strong><br />
Copy next script to a file with <em>.bat</em> extension.</p>
<p>Change <em>DATABASE_NAME</em>,<em> DATABASE_PASSWORD </em>and <em>NAMESPACE </em>according to your needs.</p>
<pre class="batch">@echo off
rem Input parameters
rem DATABASE_NAME should NOT contain spaces
set DATABASE_NAME=MyDatabase
set DATABASE_PASSWORD=mypass
set NAMESPACE=MyNamespace.Database

rem Set full path to SqlMetal.exe
rem For 64-bit Windows
set SQLMETAL="%ProgramW6432%\Microsoft SDKs\Windows\v6.0A\Bin\SqlMetal.exe"
rem For 32-bit Windows
if "%ProgramW6432%"=="" set SQLMETAL="%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\SqlMetal.exe"

rem Other parameters
set DATABASE_PATH="%CD%\%DATABASE_NAME%.sdf"
set OUTPUT_CS_PATH="%CD%\%DATABASE_NAME%.cs"
set OUTPUT_DBML_PATH="%CD%\%DATABASE_NAME%.dbml"
set CONNECTION_STRING="Data Source=\"%DATABASE_PATH%\"; Password=\"%DATABASE_PASSWORD%\";"

rem Check and run sqlmetal
if not exist %SQLMETAL% goto error-missing-sqlmetal
%SQLMETAL% /conn:%CONNECTION_STRING% /dbml:%OUTPUT_DBML_PATH% /namespace:%NAMESPACE% /context:%DATABASE_NAME%DataContext /pluralize
%SQLMETAL% /conn:%CONNECTION_STRING% /code:%OUTPUT_CS_PATH% /namespace:%NAMESPACE% /context:%DATABASE_NAME%DataContext /pluralize
goto end

:error-missing-sqlmetal
echo Error: cannot find sqlmetal.exe
echo Search location: %SQLMETAL%
goto end

:end</pre>
<p><strong>Example</strong></p>
<p>If the database is stored in <em>C:\db\Website.sdf</em> then copy script into <em>C:\db\make.bat</em>. Change <em>DATABASE_NAME</em> to <em>Website </em>and run the script. Script should generate <em>C:\db\Website.cs</em> and <em>C:\db\Website.dbml</em> files. Include the generated <em>.cs</em> file into your project.</p>
<p><strong>Using the generated code</strong></p>
<pre class="c-sharp">class Program
{
  static void Main()
  {
    //Suppose that Website.sdf has Page table with CreationDate column of type DateTime
    WebsiteDataContext db = new WebsiteDataContext(@"C:\db\Website.sdf");
    var list = from p in db.Pages
                 where p.CreationDate &gt; DateTime.Today
                 selet p;

    //Show number of pages that match Linq query
    Console.WriteLine(list.Count() + " pages created today.");
  }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/03/create-linq-to-sql-classes-from-sdf-local-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving Changes is Not Permitted?</title>
		<link>http://tech.avivo.si/2009/12/saving-changes-is-not-permitted/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=saving-changes-is-not-permitted</link>
		<comments>http://tech.avivo.si/2009/12/saving-changes-is-not-permitted/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 15:44:39 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[ms sql server]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[ntext]]></category>
		<category><![CDATA[Saving Changes is Not Permitted]]></category>
		<category><![CDATA[studio]]></category>
		<category><![CDATA[text field]]></category>
		<category><![CDATA[transact sql]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=252</guid>
		<description><![CDATA[We tried to add new ntext nullable column in MS SQL table.  We were quite surprised to get the following error message: Saving changes is not permitted.  The changes you have made require the following tables to be dropped and re-created.  You have either made changes to a table that can’t be re-created or enabled [...]]]></description>
			<content:encoded><![CDATA[<p>We tried to add new <strong>ntext </strong>nullable column in MS SQL table.  We were quite surprised to get the following error message:</p>
<p><a href="http://codeslammer.files.wordpress.com/2008/10/image15.png"><img style="border-width: 0pt;" src="http://codeslammer.files.wordpress.com/2008/10/image-thumb15.png?w=471&amp;h=117" border="0" alt="image" width="471" height="117" /></a></p>
<blockquote><p><em>Saving changes is not permitted.  The changes you have made require the following tables to be dropped and re-created.  You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.</em></p></blockquote>
<p>It wouldn’t let us add an “Allow Nulls” column?  That just seemed absurd.</p>
<p>Apparently, this is now the default behavior for any of the following changes to a table:</p>
<ul>
<li>Adding a new column to the middle of the table</li>
<li>Dropping a column</li>
<li>Changing column nullability</li>
<li>Changing the order of the columns</li>
<li>Changing the data type of a column</li>
</ul>
<p>In order to prevent this default behavior, you simply need to uncheck a box in the table designer options using the <strong>Tools -&gt; Options</strong> menu item</p>
<p><a href="http://codeslammer.files.wordpress.com/2008/10/image16.png"><img style="border: 0pt none ;" src="http://codeslammer.files.wordpress.com/2008/10/image-thumb16.png?w=244&amp;h=108" border="0" alt="image" width="244" height="108" /></a></p>
<p>Expand the <strong>Designers</strong> section to display the <strong>Table and Database Designers</strong> options.</p>
<p><a href="http://codeslammer.files.wordpress.com/2008/10/image17.png"><img style="border: 0pt none ;" src="http://codeslammer.files.wordpress.com/2008/10/image-thumb17.png?w=470&amp;h=258" border="0" alt="image" width="470" height="258" /></a></p>
<blockquote><p>To change this behavior, just <strong>uncheck</strong> the “<strong>Prevent saving changes that require table re-creation</strong>” checkbox.</p></blockquote>
<p>Original article was published at <a href="http://codeslammer.wordpress.com/2008/10/19/saving-changes-is-not-permitted/" target="_blank">http://codeslammer.wordpress.com/2008/10/19/saving-changes-is-not-permitted/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/12/saving-changes-is-not-permitted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS SQL Server Connection Strings</title>
		<link>http://tech.avivo.si/2009/10/ms-sql-server-connection-strings/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ms-sql-server-connection-strings</link>
		<comments>http://tech.avivo.si/2009/10/ms-sql-server-connection-strings/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:16:37 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[System administration]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[connection string]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[ms sql server]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=167</guid>
		<description><![CDATA[Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; Standard Security alternative syntax Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False; Trusted Connection Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; Trusted Connection alternative syntax Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; Connecting to an SQL Server instance Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True; Trusted Connection from a CE device Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;]]></description>
			<content:encoded><![CDATA[<p><strong>Standard Security</strong><br />
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;</p>
<p><strong>Standard Security alternative syntax</strong><br />
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;</p>
<p><strong>Trusted Connection</strong><br />
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;</p>
<p><strong>Trusted Connection alternative syntax</strong><br />
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;</p>
<p><strong>Connecting to an SQL Server instance </strong><br />
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;</p>
<p><strong>Trusted Connection from a CE device</strong><br />
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/10/ms-sql-server-connection-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql dump, tar, restore&#8230;</title>
		<link>http://tech.avivo.si/2009/02/mysql-dump-tar-restore/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-dump-tar-restore</link>
		<comments>http://tech.avivo.si/2009/02/mysql-dump-tar-restore/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 09:27:32 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[System administration]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[export mysql]]></category>
		<category><![CDATA[import mysql]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[migrate data]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql dump]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=37</guid>
		<description><![CDATA[Very often you need to migrate your MySQL database from one server to another, from Windows to Linux, Linux to Linux&#8230;. So, first you need to create dump of your existing database, to export it to a file. Here is the command: mysqldump -P 3306 -u database_username -p database_name &#62; /home/somedirectory/your_database.sql -P - means port, [...]]]></description>
			<content:encoded><![CDATA[<p>Very often you need to migrate your MySQL database from one server to another, from Windows to Linux, Linux to Linux&#8230;.</p>
<p>So, first you need to create dump of your existing database, to export it to a file. Here is the command:</p>
<blockquote><p>mysqldump -P 3306 -u database_username -p database_name &gt; /home/somedirectory/your_database.sql</p></blockquote>
<p><strong>-P </strong>- means port, if you don&#8217;y mention it default port is used (usually 3306)<br />
<strong>-u</strong> &#8211; means database username<br />
<strong>-p</strong> &#8211; means password but we didn&#8217;t specified it so after this command is executed we will be asked to type a password<strong><br />
database_name</strong> &#8211; is the name of your database you want to export<br />
<strong>&gt; location</strong> &#8211; at the end you specify directory where you want to create this dump</p>
<p>You probably want to zip this and you can use TAR (install Cygwin if working on Windows):<br />
Here is the command:</p>
<blockquote><p>tar cvf database.tar /home/somedirectory/your_database.sql</p></blockquote>
<p>Transfer this file on other server using FTP&#8230; And unzip it if you want using command:</p>
<blockquote><p>tar -xvf database.tar</p></blockquote>
<p>Then import the database:</p>
<blockquote><p>mysql -P 3306 -u  database_username -p new_existing_database_name &lt; /home/somedirectory/public_ftp/your_database.sql</p></blockquote>
<p><strong>-P </strong>- means port, if you don&#8217;y mention it default port is used (usually 3306)<br />
<strong>-u</strong> &#8211; means database username<br />
<strong>-p</strong> &#8211; means password but we didn&#8217;t specified it so after this command is executed we will be asked to type a password<strong><br />
new_existing_database_name</strong> &#8211; is the name of your existing database on new server where you want to import data<br />
<strong>&lt; location</strong> &#8211; at the end you specify from which directory you want to import database</p>
<p>And thats it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/02/mysql-dump-tar-restore/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

