Hi
I try to run WordPress on my MacBook and keep getting an error establishing a database connection. I try to write database name, username, password, and leave database host as localhost and leave table prefix as wp_ and seems can’t make a connection to the database. When I install mamp didn’t give me any error.
This can happen when you’ve modified or entered your database details incorrectly, such as:
Alternatively, your database could be unresponsive or corrupted.
To fix this common WordPress issue, you should first see if you get the same error on your website’s front and back end (wp-admin).
If you get a different error on the wp-admin page of your website, such as “One or more database tables are unavailable. The database may need to be repaired”, you need to repair your database.
Repairing your database is pretty simple. FTP into your website and add the following line of code into your wp-config.php file just before the ‘That’s all, stop editing!’ line:
Now save the changes, re-upload the file to your server, and visit this page:
Ignore the mydbname, myusername and mypassword. I didn’t want to write my credentials. Just change your database and password or database user name.