• Resolved alexanne86

    (@alexanne86)


    Hi All!

    I’m not the most tech-savvy so hoping you can respond in “dummy” terms. πŸ™‚

    I installed then uninstalled MAMP & WordPress. My first time around I was using info from different sources and wound up with only the MySQL server connecting. I uninstalled everything & restarted following one youtube video in hopes of success.

    Upon starting over, MAMP would connect on both servers however when I clicked, Open start page, I got the Error establishing a database connection message. This is before changing the wp-config-sample.php file, etc. I changed the url to http://localhost:8888/MAMP/ and it worked!

    However once I went forward with changing the file name to wp-config.php & updating the database name, user name & password, I got the same Error establishing a database connection message when I went to http://localhost:8888/wp-admin/install.php – I also tried http://localhost:8888/MAMP/wp-admin/install.php.

    Neither worked. Please help!!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator t-p

    (@t-p)

    Error connecting to your database: In nutshell, you’re getting this error because WP is unable to establish a database connection. Reason why WP is unable to establish a database connection can vary. It could be that your database login credentials are wrong or have been changed. It could be that your database server is unresponsive. It could be that your database has been corrupted. Majority of the times this error happens because of some sort of server error. Also, there could be other factors as well. To troubleshooting this problem:
    – double check your wp-config.php file settings for the database name, database username and database password, and the host name (e.g., “localhost” Vs. something else). This is where most errors occur.
    – Then make sure wp-config.php is in right location.
    – Then check that you don’t need to change the database host from “localhost” to something else. You can get that info from your hosting provider.
    – Check you have actually created a database with the same database name as is in your wp-config.php file.
    – Last, but not least, if all that information is correct your database probably has a problem with it. Contact your hosting provider if the database server is offline (if the problem suddenly happened), or if they have any other problem at their end, or they made any changes to your account, or if there are any limitations/restrictions, or if the hosting package is set to Windows and not Linux, etc.
    – There are also many threads on this topic on these forums: http://wordpress.org/search/Error+establishing+a+database+connection?forums=1

    Thread Starter alexanne86

    (@alexanne86)

    Thanks for the quick response – much appreciated!

    I’ve gone through your troubleshooting list & all as far as I can tell are in order. I’ve laboured through the many forums about this error and clearly a lot of people have dealt with the same issue.

    I guess my main confusion is why it had the error before I even made the file changes to wp-config.php. The first time I tried to connect, it would not with just http://localhost:8888/ but would with http://localhost:8888/MAMP/.

    I know there is something off but I keep going through all the advice and nothing seems to work. Any other ideas would be greatly appreciated!

    Moderator t-p

    (@t-p)

    it would not with just http://localhost:8888/ but would with http://localhost:8888/MAMP/.

    – Not sure if understand that.
    – did you changw the site url? Yes?
    – If you know how to access phpMyAdmin on your host, then check the wp_options Table (Note: The table prefix of wp_ may be different if you changed it when installing), and make sure siteurl field and home field are correct.

    Thread Starter alexanne86

    (@alexanne86)

    Dumb question – site url? I originally kept the same database name and created a second database with a new name to see if that would work. It did not.

    Basically I went through the steps. I downloaded MAMP. I downloaded WordPress. I transfered WordPress into the MAMP file & copied all the files over into htdocs. Before making the changes to the wp-config file I wanted to check MAMP’s connection as I had issues the last time. When I clicked “Open start page’ it opened with an error and url http://localhost:8888/. When I changed the url to http://localhost:8888/MAMP/ it opened the page Welcome! MAMP has been successfully installed.

    I then continued the steps but when got to the end step where I enter the url http://localhost:8888/wp-admin/install.php it came up with an error message.

    I accessed the phpMyAdmin on the host but I do not know how to check the wp_options table. I went through all the tabs under my database I created.

    Thank you again for your help!

    There is something not correct with your MAMP install as it should automatically open the Welcome to MAMP start page once both servers have started.

    You need to address this issue before proceeding with installing WP.

    As you indicate, the correct URL for the MAMP start page is:

    http://localhost:8888/MAMP

    I would suggest that you completely remove your existing MAMP installation (drag the MAMP folder in Applications/ to the trash and empty) then download a fresh copy from MAMP and start again.

    Once you are able to successfully click on the Open Start Page from the MAMP control panel, then proceed with the WP install.

    But do not place the install in Applications/MAMP , it belongs in Applications/MAMP/htdocs. When done, you should end up with:

    Applications/MAMP/htdocs/wordpress

    You will then start the install using:

    http://localhost:8888/wordpress

    Note too that before doing so, you need to select phpMyAdmin from the Tools menu on the MAMP start page to create a new, empty database (name it worpress for this example).

    Thread Starter alexanne86

    (@alexanne86)

    Thanks Lyle.

    I uninstalled / moved all files to trash & started over.

    This time, the Open Start Page worked (yay!) as it should. From here I proceeded with the WP install. I proceeded exactly as directed by this video https://www.youtube.com/watch?v=gP4E3KT12Zg and yet it did not work once again.

    I moved all the wordpress folder contents into the htdocs file. I removed “sample” from the wp-config file. I changed the user name, password to that provided in the MAMP welcome page & updated the database name based on the new & empty one I created in phpMyAdmin.

    I just now went in to double check that all info in the wp-config file was correct and it was however I found my mistake!!!! In case this can help anyone else and as dumb as it may be my solution was:

    The issue was with the backtics (single quotation). I just made sure they were all uniform. It was not because there was a space anywhere – I had checked that but rather I copied and pasted the backtick from below and didn’t type it in. For whatever reason it worked!

    Glad to hear that you got it working πŸ™‚

    However, also for those who may watch this video:

    – although you can install WP in the document root (htdocs), it is preferred to install within a sub folder as it keeps htdocs tidier and uncluttered which comes in handy when (if) you add more sites; and you can add as many as your hard drive has room for; that is the only limitation; and they don’t have to be WP sites; they can be Joomla!, Drupal, PrestaShop, eFront, etc.

    – a WP version or two ago, WP finally changed the text on the install page where it says to use the Create a Configuration File button instead of the re-naming the ‘-sample’ one; the reason for this, as you experienced, is that all it takes is one space where it doesn’t belong, or, as the video suggests, uses TextEdit, which by default, uses the ‘wrong’ quotes; it is best to do any edits using a plain text editor such as the free Text Wrangler

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Error establishing a database connection’ is closed to new replies.