Skip to content
Advertisement

Can not INSERT INTO Postgresql

simplechan In other words, I installed a message board named simplechan, but I can not log in to a site dedicated to the administrator. Because you need a password to get there. I do not know the password.

I entered in psql as follows

simplech_db=# select * from moderator_list;
username | password_md5 | session_id | expire_ts | actions_per_hour
----------+--------------+------------+-----------+------------------
(0 rows)

In “simplechan/sql/create_table_query.sql” it was drawn as follows.

— tables for moderator things

create extension if not exists “uuid-ossp”; — this is only required for unique session_id.

CREATE TABLE IF NOT EXISTS moderator_list (
    username text PRIMARY KEY,
    password_md5 text NOT NULL UNIQUE,
    session_id uuid UNIQUE,
    expire_ts timestamp with time zone,
    actions_per_hour int NOT NULL DEFAULT 10
); 

And I tried it like this, but it was useless. I accessed “IP / mod_login” and entered my password, but I could not put it in.

INSERT INTO moderator_list (username,md5_password) values ('my username','mypassword');
INSERT  01

When “password” is set to “md 5 _ password”, I properly INSERTed it. I accessed “IP / mod_login” and entered the password, but the password is incorrect. It was displayed. I confirmed it with “select * from moderator_list;” but it came in properly.

simplech_db=# select * from moderator_list;  
 username | password_md5 | session_id | expire_ts | actions_per_hour
----------+--------------+------------+-----------+------------------
 myuser     | mypassword     |            |           |               10

(1 row)

Advertisement

Answer

Instead of INSERTing the raw password you want to use, md5 hash it, and INSERT the result.

Find the hash of your desired password from the unix command line:

echo -n 'mypassword' | md5sum

Since the md5 hash of mypassword is 34819d7beeabb9260a5c854bc85b3e44, from psql command line enter:

INSERT INTO moderator_list (username,password_md5) VALUES ('my username','34819d7beeabb9260a5c854bc85b3e44');

Then log in with a password of mypassword

To delete that username and password combination, from the psql command line enter:

DELETE FROM moderator_list WHERE username='my username' AND password_md5='34819d7beeabb9260a5c854bc85b3e44';
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement