0

I'm trying to update a page for a MediaWiki database running MW version 1.26.4. The MediaWiki is currenty suffering unexplained Internal Server Errors, so I am trying to perform an end-around by updating the database directly.

I logged into the database with the proper credentials. I dumped the table of interest and I see the row I want to update:

MariaDB [my_wiki]> select * from wikicryptopp_page;
+---------+----------------+---------------------------------------------------------------------------+-------------------+------------------+-------------+--------------------+----------------+-------------+----------+--------------------+--------------------+-----------+
| page_id | page_namespace | page_title                                                                | page_restrictions | page_is_redirect | page_is_new | page_random        | page_touched   | page_latest | page_len | page_content_model | page_links_updated | page_lang |
+---------+----------------+---------------------------------------------------------------------------+-------------------+------------------+-------------+--------------------+----------------+-------------+----------+--------------------+--------------------+-----------+
|       1 |              0 | Main_Page                                                                 |                   |                0 |           0 |     0.161024148737 | 20161011215919 |       13853 |     3571 | wikitext           | 20161011215919     | NULL      |
...
|    3720 |              0 | GNUmakefile                                                               |                   |                0 |           0 |     0.792691625226 | 20161030095525 |       13941 |    36528 | wikitext           | 20161030095525     | NULL      |
...

I know exactly where the insertion should occur, and I have the text I want to insert. The Page Title is GNUmakefile, and the Page ID is 3720.

The text is large at 36+ KB, and its sitting on the filesystem in a text file. How do I manually insert the text into existing table row?

  • You are better off figuring out why you get errors. Manual tampering with the database will not get rid of them but might cause new ones. In any case, page content is in the text table, not page. – Tgr Oct 30 '16 at 19:48
1

As you see MediaWiki does not store the page content within table page, only the details of the page exist within that table. You need to locate the table 'text' and find the relevant row, thn use INSERT INTO.

There is a much simpler way if your not too SQL Saavy do the following:

  1. Backup the entire database using:
    • SSH Command: mysqldump -u [username] -p [database name] > [database name].sql
  2. Download the SQL backup to your local computer
  3. Open the local SQL in notepad or another editor if its too large
  4. Find the 'TEXT' row and replace with your desired content
  5. Upload the edited SQL to your server
  6. Create a new database:
    • MySQL Shell: CREATE DATABASE newdatabase;
  7. Upload the new SQL to the new database:
    • SSH Command: mysql -u [username] -p newdatabase < [database name].sql
  8. Edit the LocalSettings.php with details of the new database
  9. Test
  10. I purposely had you create another database making the old database as a backup. You can purge the old database once you are satisfied that everything is updated and working.

If you want to edit the SQL directly then you can find more information on Stack Overflow.

  • A text record can belong to multiple revisions. Also if you update it without updating the other fields (length, sha1 hash etc) it might cause strange behavior. It also won't clear caches so the changes might not show up. Directly messing with the database without understanding how the application uses it is rarely a wise move. – Tgr Oct 31 '16 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy