WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error establishing a database connection (29 posts)

  1. aehageman
    Member
    Posted 2 years ago #

    http://www.suzannemcgillivray.com.au/wp-admin/

    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at localhost. This could mean your host's database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?

    If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    I used the script below to check the database connection. Everything including my username, and password are correct.

    http://www.ardamis.com/2008/05/26/a-php-script-for-testing-a-mysql-database-connection/

    I have the hosting provider Hostgator
    looking at it now..

    I will be back with more information and a solution soon.

  2. aehageman
    Member
    Posted 2 years ago #

    Okay everyone sit down for the solution to this issue.
    It was a PEBKAC error.

    Even though I put the username in the php test page I built and it worked there, does not mean that I put it in the wp-config.php file correctly.

    Check your work letter by letter.
    So you don't waste hours because of a missing letter in your username.

    DOH!

    Off to bed.

  3. adewalelagos
    Member
    Posted 2 years ago #

    Where am i suppose to check? i looked through the wp-config file and could not find anything. see it below:

    <?php
    /**
     * The base configurations of the WordPress.
     *
     * This file has the following configurations: MySQL settings, Table Prefix,
     * Secret Keys, WordPress Language, and ABSPATH. You can find more information
     * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
     * wp-config.php} Codex page. You can get the MySQL settings from your web host.
     *
     * This file is used by the wp-config.php creation script during the
     * installation. You don't have to use the web site, you can just copy this file
     * to "wp-config.php" and fill in the values.
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', [removed]);
    
    /** MySQL database username */
    define('DB_USER', [removed]');
    
    /** MySQL database password */
    define('DB_PASSWORD', [removed]);
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         'put your unique phrase here');
    define('SECURE_AUTH_KEY',  'put your unique phrase here');
    define('LOGGED_IN_KEY',    'put your unique phrase here');
    define('NONCE_KEY',        'put your unique phrase here');
    define('AUTH_SALT',        'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT',   'put your unique phrase here');
    define('NONCE_SALT',       'put your unique phrase here');
    
    /**#@-*/
    
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each a unique
     * prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix  = 'wp_';
    
    /**
     * WordPress Localized Language, defaults to English.
     *
     * Change this to localize WordPress. A corresponding MO file for the chosen
     * language must be installed to wp-content/languages. For example, install
     * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
     * language support.
     */
    define('WPLANG', '');
    
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     */
    define('WP_DEBUG', false);
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
  4. adewalelagos
    Member
    Posted 2 years ago #

    and yet i still get this error on my site

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    Please change your database username and password immediately. NEVER post sensitive details on a public forum!

  6. adewalelagos
    Member
    Posted 2 years ago #

    thanks esmi, i just changed the details, meanwhile am so very new here and the error am getting is so killing. I posted that to see if i could get a solution asap

  7. aehageman
    Member
    Posted 2 years ago #

    well Mr esmi the moderator told you not to post usernames and passwords on a forum. and you removed them.. what you removed is what you need to verify is correct.

    use the php script in my post above to verify that you can connect to your database.. if you can connect then it is not a database connection issue.

    be sure your username password and database name are typed in correctly.

    then make sure your database hostname is localhost

  8. aehageman
    Member
    Posted 2 years ago #

    the information you posted is only sensitive if we knew which domain the information went with.
    you can give someone keys to your house, but unless they know where your home is they can not use the keys.

    Just like with your dbname, username and password. I can not test them, because I do not know where the site is. Nor do I know the hostname.

    So don't fret that you posted them, then removed them.. no one could use them unless they know where your web site is and the location of the database.

    Also you should replace your
    put your unique phrase here
    with a unique phrase.

  9. aehageman
    Member
    Posted 2 years ago #

    example of my unique phrase
    define('AUTH_KEY', 'S|&$m|&fcjJj/[9SiCN<#|)i9+hA&TUV-4p)j)k| ?pR+f7qiE$sHpD&plBg{#$<');
    define('SECURE_AUTH_KEY', 'ksQ=--{_:.]:hDv+o< 4I_qy%0G-cIBRic(tV?2,D-|3n9c<Kj=YJL6+O[[jG]=3');
    define('LOGGED_IN_KEY', '+|)ayEBj2C~7vt|[u-A@ZtRV-2

    Y2hap&uTy&gq;0rfDTC:<D{5jdpF=tUIn&|9 ');
    define('NONCE_KEY',        '{+@1VTkOhbi6DJA}c )u#BqhKf[zkoU7JZP|UbON%3nV0mZpO&9_K;e|/I5q{[nY');
    define('AUTH_SALT',        ';ax|3Wh2m/}TOp
    TJ}pEJ|D{WFE=fYl|f/H%!Yje<4tcu5s7e<k3ZK#4#i5Yqpw[');
    define('SECURE_AUTH_SALT', 'mWu@)1.{la$R-$*<|TraaosXpy1DI VmPcYGD1 p&+87[&3&g*S1:eZ3|zj&IzSS');
    define('LOGGED_IN_SALT', ':;gdzgPaO-u]=)~-d#nk?.qKBw8fs?=qK;<?8Hb52me)BfzO]NQFKx7B.BDb@#}w');
    define('NONCE_SALT', 'UrqQ,Q>RFopWk>;Kd_s?+[xtSN;})MkvY]Wx<<wktf/(i@X3Sc`/=xug|7jS0;9G');

  10. adewalelagos
    Member
    Posted 2 years ago #

    you know i really do not know what to do with the codes after following the link, if you can simplify it for me step by step what to do i'll so appreciate it

  11. adewalelagos
    Member
    Posted 2 years ago #

    i did not remove the information above, mode did. Thanks

  12. esmi
    Forum Moderator
    Posted 2 years ago #

    Check your database details with your hosts.

  13. adewalelagos
    Member
    Posted 2 years ago #

    i guess am suppose to feel in my db name,db user and password then run it in a browser or am i suppose to create a file with this and upload it to my account, suggestions will be appreciated.

    Thanks

  14. esmi
    Forum Moderator
    Posted 2 years ago #

    It can be even easier. Delete your wp-config.php file and just go straight to http://your_domain/wp-admin/install.php. WordPress will ask you for your database details and create the wp-config.php file for you.

  15. adewalelagos
    Member
    Posted 2 years ago #

    Thanks esmi, i used your suggestion and my site seem better now, i will observe it to see if the error does not come back. Once more am really greatful

  16. esmi
    Forum Moderator
    Posted 2 years ago #

    Glad I could help :-)

  17. adewalelagos
    Member
    Posted 2 years ago #

    Hello Esmi, the error is back, i get it on the back end and front end, it gives access after reloading the page for up to 10 times and it comes back againg

  18. esmi
    Forum Moderator
    Posted 2 years ago #

    This is a database error, yes? Have you asked your hosts about it? Do you have access to your site's error logs?

  19. adewalelagos
    Member
    Posted 2 years ago #

    I have access to my site but i don't really know where to read the error log. When i contacted bluehost they said my site is running fine, another support person said it's caused by a plugin i deleted all plugins,switch theme and nothing happened, i tried to live with but it's getting worse. What can you suggest Esmi?

    Thanks/

  20. esmi
    Forum Moderator
    Posted 2 years ago #

    Ask Bluehost where your error logs can be found. In the meantime, try:
    - switching to the Twenty Eleven theme by renaming your current theme's folder inside wp-content/themes and adding "-old" to the end of the folder name using FTP or whatever file management application your host provides.

    - resetting the plugins folder by FTP or phpMyAdmin.

    That said, I find it difficult to believe that a plugin could cause this error.

  21. adewalelagos
    Member
    Posted 2 years ago #

    Hi Esmi i chat with Aaron from Bluehost and he said my "account is currently being throttled. This generally means there are processes or queries being abusive to the server, and using up a good majority of the servers overall resources". he also gave me a link to try to resolve it and another link to drop ticket with their cpu guys, however i will also appreciate any suggestion on this. Thanks.

  22. esmi
    Forum Moderator
    Posted 2 years ago #

    The most common culprits here are too many installed plugins or a particularly intensive plugin or theme. Can Bluehost give you any indication of where the queries are coming from?

  23. adewalelagos
    Member
    Posted 2 years ago #

    When i loggeg into CPU Throttling i saw this:

    Warning

    Your account is actively experiencing CPU limiting factors (throttling).
    During the past 24 hours your account has been throttled for a total of 85618.575 seconds.

  24. esmi
    Forum Moderator
    Posted 2 years ago #

    Try asking Bluehost for more information. In the meantime (and assuming you cannot login to your site), try:
    - switching to the Twenty Eleven theme by renaming your current theme's folder inside wp-content/themes and adding "-old" to the end of the folder name using FTP or whatever file management application your host provides.

    - resetting the plugins folder by FTP or phpMyAdmin.

    That should cut the site's use of resources down to an absolute minimum.

  25. adewalelagos
    Member
    Posted 2 years ago #

    I can log into my site, i even manage to update contents but the error just come and go.

    The instruction below is what Bluehost gave me to follow and i was able to get some idea.

    How can you troubleshoot this?

    Within your Bluehost cPanel under the logs category you will find the "CPU THROTTLING" icon. This tool will show you exactly how many seconds your account has been throttled during the past 24 hours. This data is valuable when analyzed along with other logs such as MySQL Slow Queries.

    The MySQL Slow Queries log can help determine which queries or scripts are unoptimized. Login into cPanel. Look for the section called "Files" and click the icon called "File Manager". Start in the "Home Directory", choose Show Hidden Files, and then click Go. Once in the File Manager, look on the right side for a folder called "tmp" and navigate into that folder. Once inside the tmp folder, find a folder called "mysql_slow_queries". Navigate inside that folder.

    Look for the files with recent dates and right-click on one of those files and choose "Code Edit". This will show the log details. Look for the logs where the Query_time is over 2 seconds. Queries that take over 2 seconds to execute usually need to be re factored.

    These logs are generated to help troubleshoot database programming queries that are not optimized. Locate the query and database causing the problem, then optimize the query or queries by re-writing the query, creating an appropriate Database Index, repairing any damaged databases, etc. If you are not familiar with database programming, you may need to seek help from your web developer/programmer.

    ***** WE STRONGLY RECOMMEND THAT YOU BACKUP YOUR DATABASES BEFORE WORKING ON THEM *****

    in the Mysql query, some queries are took 2.436871,4.684169,6.019225 and other queries took less than 2 seconds. I really don't know how to transfer this since i have no programming skills am only good at following instructions. Don't know if it is wise to post all the Msql queries here to see if you can help me figure it out.

    NB: Visitors maps who's online plugin was stated in most of the queries that took so long, i don't know what this mean.

    Thanks.

  26. esmi
    Forum Moderator
    Posted 2 years ago #

    Deactivate all plugins
    Switch to the Twenty Eleven theme
    Then post a link to your site.

  27. adewalelagos
    Member
    Posted 2 years ago #

    my site is a buddypress install site and i don't get the post a link to you site part does it mean that i should post a content or something.

    Thabks.

  28. adewalelagos
    Member
    Posted 2 years ago #

    I just went to the support forum of visitor's maps plugins and it seems everybody is complaining thesame thing with no much response from the plugin owner, i guess it is causing my problem and i could recall i started having this problem at about the time i discovered that plugins. May i know how to remove the plugin and drop it's table from my database so it files will be clean from my account.

    Thanks

  29. esmi
    Forum Moderator
    Posted 2 years ago #

    i don't get the post a link to you site part

    It means post a link to your site here so we can have a look at it.

Topic Closed

This topic has been closed to new replies.

About this Topic