How to add WordPress admin user via database

Sometimes there might be a need to create a new WordPress admin user via database. For example, when the only admin user is accidentally locked out or in new installations where the admin user is not yourself.

Here are the steps:

https://wpengine.com/support/add-admin-user-phpmyadmin/

Convert a notnull()-vs-isnull() column to 1-vs-0

Sometimes a binary column’s True-vs-False value is differentiated by a fixed value vs NaN. For example:

Is Good
=============
Is Good
NaN
Is Good
Is Good
NaN
.
.
NaN

In this case, there might be value in converting the values in the column to ones and zeros.

def convert_to_1_0(list_of_column_names, data, inplace = False):
df = data if inplace else data.copy()
for col_name in list_of_column_names:
df.loc[df[col_name].notnull(), col_name] = 1
df.loc[df[col_name].isnull(), col_name] = 0
df = df.astype({col_name:int})
if not inplace:
return df

Note: inplace=True doesn’t work in the code above. Use inplace=False instead.