-
-
Notifications
You must be signed in to change notification settings - Fork 41
LSP Database Management
Tres Finocchiaro edited this page Jan 5, 2022
·
4 revisions
You'll need to be granted SSH access by sharing your public key with a server admin.
-
At the console, login to MySQL as
lsp
mysql -u lsp -p
-
Select the
lsp
databaseuse lsp;
-
Determine which table you'd like to touch
show tables;
Example:
# +---------------+ # | Tables_in_lsp | # +---------------+ # | categories | # | comments | # | files | # | filetypes | # | licenses | # | ratings | # | subcategories | # | users | # +---------------+ # 8 rows in set (0.00 sec)
-
Determine the table layout by selecting the first record:
select * from comments limit 1
Example:
# mysql> select * from comments limit 1; # +----+---------+---------+---------------------+---------------------------------------------+ # | id | user_id | file_id | date | text | # +----+---------+---------+---------------------+---------------------------------------------+ # | 1 | 555 | 555| 2011-02-15 05:22:91 | What a nice song, thanks for sharing! | # +----+---------+---------+---------------------+---------------------------------------------+ # 1 row in set (0.01 sec)
-
Delete by
id
or a very unique pattern... Don't forget the semicolon at the end!-- CAREFUL -- CAREFUL --- CAREFUL delete from comments where id = 1;
-
Alternately, you may delete by other fields...
select * from comments where user_id = 555 and file_id = 555; (1 row returned) -- CAREFUL -- CAREFUL -- CAREFUL delete from comments where user_id = 555 and file_id = 555; (1 row affected)
-
Or by pattern...
select * from comments where text like '%very bad word%';
-
Reset a user's password:
update users set password = LOWER(SHA1('some_new_password')) where login = 'some_valid_user_name';
-
Ctrl+D
to logout of MySQL -
Ctrl+D
again to logout of SSH