Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Error establishing a database connection

I am new to WordPress, and I am trying to setup it at my local machine.

I am getting error like "Error establishing a database connection".

I tried all solutions from WP blogs,

    1. created new user with all privileges
    1. tired with root user.
    1. created and deleted the target database multiple times.

Nothing is working.

Does anyone know anything else I can try?

like image 335
Shashikant Avatar asked Dec 22 '25 08:12

Shashikant


2 Answers

Error establishing a database connection doesn't get any simpler than that. Your password, database name, user name, or host is wrong. See http://codex.wordpress.org/Common_WordPress_Errors#Error_Establishing_Database_Connection

Are you sure about using localhost as the server? Are you using MAMP or WAMP?

Try using Adminer http://www.adminer.org/ on your PC/Mac to find the database name, etc., and to admin the database when needed.

If you know can use a shell, try logging into the MySQL server and trying

mysql> show databases;

to list all databases to check your database name.

And try

mysql> mysqlserverinfo --server=root:pass@localhost -d --format=vertical

to get port info, etc. See http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqlserverinfo.html

like image 154
markratledge Avatar answered Dec 23 '25 22:12

markratledge


I used MAMP for the MySQL server, and used its phpMyAdmin interface to create the database for WordPress and specify its user and password.

Host, for the new database, was "%" on the "User" tab of phpMyAdmin, which it said was supposed to allow any value, and did let me get a certain way through the process. But, I ended up going into "Login Information" under the "User" tab in phpMyAdmin, and changing "%" to "localhost".

That allowed me to finish setting up WordPress.

like image 24
Buzz Avatar answered Dec 23 '25 22:12

Buzz