bitcoin-qt and bitcoind are built from the same source code. They largely use the same settings, data directory, and configuration file.

However, bitcoin-qt has a set of options that are specific to it. These settings are stored in a separate Qt defined location (on Windows, it's stored in the registry). bitcoind cannot read these settings. If you set your data directory by choosing the location in the dialog box that appears the first time you started, the data directory location is stored in the Qt specific settings so bitcoind cannot read it.

You can set the data directory for bitcoind by creating a bitcoin.conf file in the default data directory location (on Windows, that's %APPDATA%/Bitcoin) and adding the line


where <path> is the path to where you want the data directory to be.

Or by adding -datadir=<path> to the command you are using to start bitcoind.

I use bitcoind -datadir=D:\bitcoin to do that, is it right?

Yes, that is correct.

In my home directory (C:\Users\MyName) or just in the same data directory (D:\bitcoin)?

You should put the config file in the data directory that the software will open initially. If you are setting -datadir in your startup command or the datadir is specified in your Qt settings, then you should put the config file in the data directory.

If not, you should put it in the default data directory location which is C:\Users\<username>\AppData\Roaming\Bitcoin.

Does bitcoind and bitcoin-qt use the same configure file?