Here's exactly what happened, step by step.
Why the old password couldn't come back
WordPress never stores your actual password. In the database table wp_users, the user_pass column holds only a one-way hash (modern WordPress uses bcrypt via its phpass library). A hash can't be reversed, so "retrieve" was impossible — the only way back in is to overwrite the hash with a new one.
1. Found your account
WordPress runs on this machine's MariaDB database (the wp database, data in ~/data/mysql). I connected to it as root through the local socket — no password needed for that, since MariaDB trusts the machine's root user — and listed the users:
SELECT ID, user_login, user_email FROM wp.wp_users;
There's exactly one account: ID 1, username admin.
2. Generated a new password
openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c 16
Random bytes, filtered down to 16 letters and digits so it's easy to type. It was shown only here in chat — I didn't save it in any file or memory.
3. Overwrote the hash:
UPDATE wp.wp_users SET user_pass = MD5('<new-password>') WHERE ID=1;
This is the part that looks odd, so here's why MD5 is safe here: WordPress's login checker (wp_check_password) still understands legacy MD5 hashes for backward compatibility. When you log in with the new password, it checks md5(your input) against the stored value, and on success it immediately re-hashes the password into the modern bcrypt format and updates the database. So the MD5 hash is only a one-time bridge — after your first login, what's stored is a strong bcrypt hash again, same as if you'd set the password through WordPress itself.
4. Verified it took:
SELECT user_login, LENGTH(user_pass) FROM wp.wp_users WHERE ID=1;
It returned admin with a 32-character hash — exactly MD5 length — confirming the overwrite landed. No restart was needed: WordPress reads the database fresh on every login attempt, so the change was live instantly.
Why not the other ways
- The "Lost your password?" email link on wp-login.php wouldn't work here — there's no mail server on this machine, so the reset email would never arrive.
- WP-CLI (
wp user reset-password) would do the same thing more elegantly, but it isn't installed, and the database update achieves the identical result.
One thing to note: the database password in wp-config.php is a different credential entirely — that's what WordPress itself uses to talk to MariaDB, and I didn't touch it.

所获得的博客网址原本是https://wp.luckypoem.workers.dev/,后来我要muse把它删除了。
在muse的vm上搭建的博客网址换成了wp.mingsea.net
当然还是要靠cloudflare tunnel把muse的vm上搭建的wordpress博客暴露到(连接到)公网。



















No comments:
Post a Comment