System Preferences locked After Username Change

i have a problem with my MacBook Air. I recently changed the username and now if I want to unlock 'users and groups' or If I want to make changes that require the administrator information (username and password) the system doesn't recognize me. What should I do? is it possible to create a new administrator account to replace the old one without losing all my files?

EDIT: I can't even create a new user account.


Solution 1:

Have a backup, then:

  1. Create a new administrator account by re-running the setup assistant. You can do this by deleting /var/db/.AppleSetupDone from single-user mode. See I don't have administrator account on my mac
  2. Delete your existing user account from System Preferences, keeping the home folder.
  3. Rename the home folder with the new username you want to use if you haven’t already done so.
  4. Create a new user account with the correct username. You should be prompted to use the existing home folder you renamed:

    The Users folder already contains a folder with the same name as the home folder for this account.