You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

WordPress用户遗忘SQL账号密码及数据库连接问题咨询

Hey there! Let's tackle your two questions one by one:

1. Are the username and password in wp-config.php the same as the SQL credentials?

Yes, absolutely! The DB_USER and DB_PASSWORD values in your wp-config.php file are exactly the credentials WordPress used to connect to your original MySQL database on your old host. That means they match the SQL username and password you had back when your site was live.

Just a quick note though: if you're setting up your site locally with MAMP, you'll need to update these values to match MAMP's default MySQL credentials (usually username root and password root — though some older versions might use an empty password). Your old wp-config values won't work for the local MAMP database unless you manually create a matching user in MAMP's MySQL.

2. How to fix the "Error Establishing network connection" when importing SQL backup via phpMyAdmin in MAMP?

This error usually points to a connection issue between phpMyAdmin and MAMP's MySQL server. Here are some practical troubleshooting steps to try:

  • Check if MySQL is running: Open MAMP and make sure the MySQL server is marked as "Running". If not, click "Start Servers" to launch it. Sometimes servers fail to start if another service is using the default MySQL port (3306), so MAMP might switch to port 8889 instead — keep an eye on the port number shown in MAMP's interface.
  • Verify phpMyAdmin's connection settings: MAMP's phpMyAdmin is pre-configured to connect to its own MySQL instance, but sometimes settings get mixed up. You can check the config file at MAMP/bin/phpMyAdmin/config.inc.php:
    • Ensure $cfg['Servers'][$i]['host'] is set to localhost
    • Confirm $cfg['Servers'][$i]['port'] matches the MySQL port displayed in MAMP (usually 8889)
    • Make sure $cfg['Servers'][$i]['user'] and $cfg['Servers'][$i]['password'] are set to root (MAMP's default credentials)
  • Prepare the database before importing: Before uploading your backup, create a new empty database in phpMyAdmin (use the same name as your original site's database, which you can find in wp-config.php under DB_NAME). Select this database first before starting the import — this avoids issues with the backup trying to access a non-existent database.
  • Inspect your SQL backup file: Open the backup file in a text editor and look for any host-specific commands (like CONNECT statements pointing to your old host's server). If you find any, remove them — they'll cause connection errors locally. Also, check for corrupted sections in the file that might break the import process.
  • Restart MAMP: Sometimes a simple restart fixes glitches with the server connection. Stop both Apache and MySQL in MAMP, wait 10 seconds, then start them again.

内容的提问来源于stack exchange,提问作者user9504869

火山引擎 最新活动