In geth using Mist I noticed that I have 2 keystores in two different places. One for the main blockchain in Users/<user>/Library/Ethereum/keystore/ (OS X) and on testnet in Users/<user>/Library/Ethereum/testnet/keystore/.

I also have a private chain that I am setting up in an entirely different directory.

I haven't mined yet because I want to create a new account, but when I did create one from the command line geth account new it placed it in the keystore for mainnet.

I would say this is potentially very confusingat best dangerous at worst, especially if you demo using private blockchains and backing them up.

I'm guessing I'm missing a command argument of some kind to force the creation of a different keystore. How do I do that?

2 Answers 2


Accounts are stored in the keystore subdirectory. You can use --datadir to set that main directory, but the subdirectories are still going to be intact.

In order to change the keystore directory you need to use --keystore

From CLI Options:

--datadir "/home/youruser/.ethereum" - Data directory for the databases and keystore

--keystore - Directory for the keystore (default = inside the datadir)

The reason you have different folders for testnet, mainnet, etc. is to keep your testnet accounts separate from your mainnet ones. This is important.

I believe you need to move to the testnet, then create the account in the testnet, and then mine in the testnet in order to keep everything on the testnet. It sounds like you are straddling the two and potentially using an account on the mainnet rather than the testnet. Make sure you are actually on the testnet because simply changing the keystore directory on the mainnet is not enough.

  • Do you also have to explicitly specify the directory with --keystore or does the inclusion of the --datadir "/path/to/chain/directory" do enough?
    – T9b
    Apr 15, 2016 at 23:53
  • It seems --keystore is no longer available in geth version 1.3.5.
    – T9b
    Apr 16, 2016 at 0:04
  • It seems this is the answer geth --datadir "/path/to/chain/directory" account new nothing else is needed.
    – T9b
    Apr 16, 2016 at 0:21
  • 1
    @T9b I still see --keystore in recent versions of Geth. If you also see --keystore, can we clean up these comments?
    – eth
    Aug 7, 2016 at 8:50

Basically, --datadir option must be spcified with most commands if you're using custom datadir.

account, attach, export/import, removedb ...

I recommend you to make a short script like below

geth --datadir "<Your datadir>" $@ save this like geth.sh and then execute any command like geth.sh attach way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.