ICloud – How to delete GameCenter and iCloud from Internet Accounts using the Terminal

accountsdefaultsicloudsystem-prefsterminal

Running Sierra 10.12.6 without administrator privileges, the system has some problem with my iCloud profile. Whenever accessing anything remotely related to it, the respective app beachballs indefinitely. This includes the Preferences pane, so I could not even delete my account from there. I managed to find the necessary Terminal command:

defaults delete MobileMeAccounts

It worked, almost. Even without root access/sudo, this indeed reset the iCloud pane in Preferences, but it did not remove the iCloud and Game Center entries from the Internet Accounts pane. They are merely listed as inactive or disabled (I'm not using the English locale). If I select either of them, Preferences still beachballs, of course.

How can I permanently remove those accounts using the Terminal, probably using defaults?

For what it's worth, this did not do the trick:

defaults delete com.apple.gamecenter

PS: If you want to suggest solutions to the underlying iCloud problem, please use comments instead of answers.

Best Answer

The Internet accounts are stored in ~/Library/Accounts/Accounts4.sqlite.

  • give your terminal full disk access or you can't access ~/Library/Accounts
  • create a backup (e.g. cp ~/Library/Accounts ~/Library/Accounts.bak
  • open it with sqlite3 or any other sqlite client such as DB Browser for SQLite
  • give full disk access to your sqlite client (important if using a client with a GUI or its own wrapper, such as the above)
  • SELECT * from ZACCOUNT;
  • delete the row you want gone
  • save
  • reopen Internet Settings

This helped me get rid of a broken Game Center account on Big Sur. The account caused the Internet Accounts dialog to freeze.

credits: https://www.telnetport25.com/2020/04/macos-catalina-there-was-an-error-in-internet-accounts-preferences/