Arafat Rahman
Arafat Rahman

Reputation: 1015

Error establishing a database connection in my localhost

I am trying to install Wordpress in my localhost Xampp server

But every time I got an error message with

error establishing 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.

I have already googling but not get the correct answer yet.

I add define( 'WP_ALLOW_REPAIR', true ); in wp-config.php but not solved.......

Upvotes: 0

Views: 31071

Answers (2)

Ashish
Ashish

Reputation: 83

in such case you can use the localhost ip like hostname 127.0.0.1:3308 Here 3308/3307 will be your xampp port

Upvotes: 0

Brennan Walsh
Brennan Walsh

Reputation: 460

This means wordpress can't find your database.

Navigate to http://localhost/phpmyadmin. Where it says create new database, choose a name for your database.

Next, open up wp-config.php in the root of your wordpress folder, and update the four values shown below to reflect your new database.

The default credentials for your newly created database are:

  1. DB_NAME: Your chosen db name (case sensitive)
  2. DB_USERNAME: root
  3. DB_PASSWORD: ""
  4. DB_HOST: localhost
/** The name of the database for WordPress */
define('DB_NAME', 'case sensitive chosen db name');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Upvotes: 9

Related Questions