Stuck when installing WP – “Error establishing a database connection”



Make sure that your MySQL server is running. Check it in WAMP. And check the database using phpMyAdmin with the credential you have used.

Dear Joy
Thank you for answering me.
I have checked in WAMP that the MySQL server is running – it is.
I have checked the database in myPHPadmin and, as far as I can see (not fluent in these areas) that is OK.
From wpconfig.php,

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘sal_wordpress’ );

/** MySQL database username */
define( ‘DB_USER’, ‘sally_wordpress’ );

/** MySQL database password */
define( ‘DB_PASSWORD’, ‘xyz123abc’ );

/** 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’, ” );

However, I have some confusion. At the head of the myPHPadmin page, it shows Server: MySQL:3308 »Database: sal_wordpress, while in ” Users having access to “sal_wordpress”
is showing
User name Host name
sally_wordpress localhost

I look forward to your advice, and again thank you for your help.



That all looks correct, but I can only see what you show…
I’m sure you’re already be reading this page
but see if there’s anything there that you might have skipped or put in the wrong place (like a folder installation versus a root installation).

The first thing you should try is to change DB_HOST to the following:

define('DB_HOST', 'localhost:3308');

If you receive the same “Error establishing a database connection” message, go back to phpMyAdmin, and in the same section you found the Server information, please post the line for User.

To Dion Designs
Sorry for silence, covid19 etc is disturbing life.
First, I have uninstalled and then reinstalled wordpress, and the database and daabase user, to make sure the installs are ‘clean’.

I included the line you suggested, define(‘DB_HOST’, ‘localhost:3308’); , with the result on running wp-config.php:
The file wp-config.php already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.
The words ‘install now’ has a link on it. On clicking on that link, I am returned to the error page I had before.
My version of phpMyAdmin has User Accounts rather tha Users.
Here is the relevant line:
sal_wordpress localhost password: Yes ALL PRIVILEGES Yes Edit privileges Export

Thank you for your help, I look for ward to seeing your advice.
Stay safe.

@diondesigns is right instead of using localhost, add the port as well, such as localhost:8889

To note, this is for local installation through MAMP

Thank you @diondesigns

Source link