user5065: I had Bitcoin-Qt on my computer with several bitcoins in my wallet, using Vista. Then my computer crashed.  Finally I was able to get my computer fixed and download a new version of Bitcoin-Qt.  Now I would like to import my original wallet.dat from the old client which was encrypted into an new version of Bitcoin-Qt.  How do I do that?  

user96053: the other answers suggest closing your node copying directories etc, NOT necessary. Here is how i did it starting with an old wallet2.dat file:

create a folder foo (any name, any directory)
copy the file wallet2.dat into folder foo and rename the wallet to wallet.dat
on the GUI click Window->Console and type into the > field: help loadwallet which will tell you bunch of stuff (you can read it, or skip to next point)
type loadwallet /path/to/your/folder/foo (change it to your actual path where folder foo is, on windows eg C:\Users\user\Downloads\foo)
wait, just wait (for me 30min), when done you will see sth like:
{
  "name": "/home/user/Downloads/foo/",
  "warning": ""
}
got to File->Open Wallet -> foo (your name should be listed here)
On the right side there is now a dropdown menu where you can selected your open wallets (if it does not appear you had no other wallet open, also ok)


(Since the wallet is now located in the folder foo and outside the datadir, you might want to close your node and copy the folder into the wallets directory in your datadir; I just wanted to recover the wallet, clean it and send the funds to the default wallet deleting foo anyway)

user9822: For OSX:

Backup your original wallet.dat file (~/Library/Application Support/Bitcoin/wallet.dat by default). This contains the private keys for your bitcoins. If you lose it, you lose your coins.
Install Bitcoin Core on a machine with 100s of gigabytes of free space. Allow it to download the blockchain. This could take days.
Replace the wallet.dat file on the new machine with your old one.
Start Bitcoin Core on the new machine with the rescan flag, to scan the blockchain for your newly imported bitcoin. You can do this with the command line /Applications/Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt -rescan. This can also take a long time (hours).
Your wallet should now be imported and working on the new computer.


user1307: First, close the Bitcoin-Qt client.
Then you have to locate your Bitcoin folder. For Windows, it should be here:
%APPDATA%\Bitcoin
and for Linux:
~/.bitcoin
In that folder, there should be a wallet.dat file.

If you currently have no bitcoins in your wallet, you can just delete that file and replace it with your backup.
If you have some bitcoins in this wallet as well, backup that wallet file as well, or send all the coins to an address from your backed up wallet.

When you placed the other wallet.dat file in place, you should run Bitcoin-Qt with the -rescan option. Here's how to do that in Windows:

Go to C:\Program Files (x86)\Bitcoin using Windows Explorer.

In that folder, hold shift and right-click and select Open command window here (picture).

In the command prompt, type bitcoin-qt.exe -rescan and hit enter (picture).


Now Bitcoin-Qt should start and rescan the blockchain to calculate the balances of the addresses in your wallet.dat file.
(Source for pictures: cant see bitcoin after restore of backup)

5065: <p>I had Bitcoin-Qt on my computer with several bitcoins in my wallet, using Vista. Then my computer crashed.  Finally I was able to get my computer fixed and download a new version of Bitcoin-Qt.  Now I would like to import my original <code>wallet.dat</code> from the old client which was encrypted into an new version of Bitcoin-Qt.  How do I do that?  </p>
 96053: <p>the other answers suggest closing your node copying directories etc, NOT necessary. Here is how i did it starting with an old <code>wallet2.dat</code> file:</p>

<ol>
<li>create a folder <code>foo</code> (any name, any directory)</li>
<li>copy the file wallet2.dat into folder <code>foo</code> and rename the wallet to <code>wallet.dat</code></li>
<li>on the GUI click Window->Console and type into the > field: <code>help loadwallet</code> which will tell you bunch of stuff (you can read it, or skip to next point)</li>
<li>type <code>loadwallet /path/to/your/folder/foo</code> (change it to your actual path where folder foo is, on windows eg <code>C:\Users\user\Downloads\foo</code>)</li>
<li><p>wait, just wait (for me 30min), when done you will see sth like:</p>

<p>{
  "name": "/home/user/Downloads/foo/",
  "warning": ""
}</p></li>
<li><p>got to File->Open Wallet -> <code>foo</code> (your name should be listed here)</p></li>
<li><p>On the right side there is now a dropdown menu where you can selected your open wallets (if it does not appear you had no other wallet open, also ok)</p></li>
</ol>

<p><a href="https://i.stack.imgur.com/LI2cK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LI2cK.png" alt="enter image description here"></a></p>

<p>(Since the wallet is now located in the folder foo and outside the datadir, you might want to close your node and copy the folder into the <code>wallets</code> directory in your datadir; I just wanted to recover the wallet, clean it and send the funds to the default wallet deleting foo anyway)</p>
 9822: <p>For OSX:</p>

<ol>
<li>Backup your original wallet.dat file (<code>~/Library/Application Support/Bitcoin/wallet.dat</code> by default). This contains the private keys for your bitcoins. If you lose it, you lose your coins.</li>
<li>Install Bitcoin Core on a machine with 100s of gigabytes of free space. Allow it to download the blockchain. This could take days.</li>
<li>Replace the <code>wallet.dat</code> file on the new machine with your old one.</li>
<li>Start Bitcoin Core on the new machine with the <code>rescan</code> flag, to scan the blockchain for your newly imported bitcoin. You can do this with the command line <code>/Applications/Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt -rescan</code>. This can also take a long time (hours).</li>
<li>Your wallet should now be imported and working on the new computer.</li>
</ol>
 1307: <p>First, close the Bitcoin-Qt client.</p>
<p>Then you have to locate <a href="https://en.bitcoin.it/wiki/Data_directory#Default_Location" rel="noreferrer">your Bitcoin folder.</a> For Windows, it should be here:</p>
<p><code>%APPDATA%\Bitcoin</code></p>
<p>and for Linux:</p>
<p><code>~/.bitcoin</code></p>
<p>In that folder, there should be a <code>wallet.dat</code> file.</p>
<ul>
<li>If you currently have no bitcoins in your wallet, you can just delete that file and replace it with your backup.</li>
<li>If you have some bitcoins in this wallet as well, backup that wallet file as well, or send all the coins to an address from your backed up wallet.</li>
</ul>
<p>When you placed the other <code>wallet.dat</code> file in place, you should run Bitcoin-Qt with the <code>-rescan</code> option. Here's how to do that in Windows:</p>
<ul>
<li><p>Go to <code>C:\Program Files (x86)\Bitcoin</code> using Windows Explorer.</p>
</li>
<li><p>In that folder, hold shift and right-click and select <code>Open command window here</code> (<a href="https://i.imgur.com/nXe5tSn.jpg" rel="noreferrer">picture</a>).</p>
</li>
<li><p>In the command prompt, type <code>bitcoin-qt.exe -rescan</code> and hit enter (<a href="https://i.imgur.com/KNBgzTS.jpg" rel="noreferrer">picture</a>).</p>
</li>
</ul>
<p>Now Bitcoin-Qt should start and rescan the blockchain to calculate the balances of the addresses in your <code>wallet.dat</code> file.</p>
<p>(Source for pictures: <a href="https://bitcoin.stackexchange.com/questions/7731/cant-see-bitcoin-after-restore-of-backup#comment10112_7734">cant see bitcoin after restore of backup</a>)</p>
