Database Error – Error Establishing a Database Connection
“Database Error: Error establishing a database connection”
I was able to fix the problem right away because I knew what the problem was. The database name and password are stored on 2 different places. Information in both places must match before permission to connect to the database is granted.
- When you WordPress, the database name and password were automatically generated
- This database username and password is stored in 2 different places: 1. a static config file in your file server and in the 2. Dreamhost account.
- The database username and password is stored in Dreamhost so you can manage the user privileges
- The database username and password is stored on the config on file server as a connection document since files need to constantly talk to your database.
- If you change the password in Dreamhost account, but not in the WordPress config file, you will get this error message.
Overview of How to fix:
Well I chose to change the password on the WordPress file server, so these are the high level steps that I took:
- Edit user name to have SSH access in Dreamhost
- Find the current database password in Dreamhost
- SSH into your domain name and edit the WordPress config file in the File Server
1. Edit FTP User name to have SSH access in DreamhostDreamhost – Allow FTP User SSH Access
Enable your FTP user to have SSH access so you can telnet into your account/or you can choose to use FTP the file. In that case you can skip to Step 2.
- Login to your Dreamhost panel
- Click on ‘Manage Users’, Click on ‘Edit’ for your username
- In Manage Users window, Editing User, set the following value:
- User Account Type = Shell account – allows SFTP/FTP plus ssh access.
- Click on ‘Save Changes’
2. Find the Current Database Password in DreamhostDreamhost- Edit the Database User
- Click on ‘ ’
- Under ‘Databases on this server’, select the ;User with Access’
- Under at the bottom, you will see ‘Password Currently”. For example – myNEWpassword
- You can copy that password to be used in Step 3
3. SSH into domain and Edit WordPress Config File
- Telnet or SSH into your domain name with the username and password from Step 1
- cd into your website directory
- Search for code that says:
- Change the password to the new password from Step 2
- Press ‘Control-X’ and save your file
After you save your file and refresh your website, the error message should disappear.
Hope that helps!
BTW, all the information I listed above are all sample data. None of these username, password, db_hostname, database names are valid on my website.