skwerlman skwerlman - 3 months ago 9
SQL Question

How do I correctly use the WHERE clause?

I'm currently attempting to manually remove 2FA for my GitLab server's administrator account, since I've lost access to both my OTP app, and the recovery keys for the account.

There is only one account with administrator access.

According to this comment, the correct way to do this is to set

otp_required_for_login
to
false
for that user.

I have found my way into the database debug console (
sudo gitlab-rails dbconsole
; it's basically a wrapper for
psql
), and am now trying to actually change the value. However, I get a syntax error when running my query.

My query:

UPDATE "users"
SET "otp_required_for_login" = false
WHERE username = "gl_administrator";


The syntax error I get:

ERROR: syntax error at or near ""gl_administrator""
LINE 3: WHERE username = "gl_administrator";
^

Answer

You must use single-quotes when referencing a string literal.

So, your query would simply change to:

WHERE username = 'gl_administrator';