WordPress Error Establishing A Database Connection Mac Os X


Installing WordPress Locally on Your Mac With MAMP

What is MAMP?

MAMP stands for Macintosh, Apache, MySQL, and PHP. MAMP is an application you can install on your Mac which allows you to have access to a local PHP server and MySQL server. Essentially, MAMP gives you all of the tools you need to run WordPress on your machine, for development and testing purposes. You can accomplish this in different ways, but the other ways aren’t nearly as simple (see MacOS_X_Local_Mirror for the long, manual version of installing PHP and MySQL on your Mac).

Step 1: Installing MAMP

Before you can install MAMP on your Mac, you’ll need to download it from the MAMP website. MAMP requires that your Mac be running Mac OS X 10.6.6 or later.

Once the MAMP download is complete, double-click the MAMP disk image (it should be something like MAMP_2.0.3.dmg), and you should get a MAMP window pop up. Drag the MAMP folder (not MAMP PRO – we’ll save that walk-through for another time) to the Applications folder.

Step 2: Basic MAMP Settings

Now that you’ve got MAMP installed on your system, launch MAMP.app (located at /Applications/MAMP/MAMP.app).

While you’re editing settings, MAMP might prompt you for an administrator password. This is required because MAMP needs to run two processes: mysqld (MySQL) and httpd (Apache), and depending on the settings you set for those processes, you may or may not need to input your password.

Once you open MAMP, click the Preferences button. Next, click over to "Ports." The default MAMP ports are 8888 for Apache, and 8889 for MySQL. If you use this configuration, you shouldn’t get asked for your password, but you’d need to include the port number in the URL (localhost:8888). If you’d like to leave the port number out of the URL, change the Apache port to 80. The downside of using port 80 as your MAMP Apache port is that you’ll always be asked for your password.

Lastly, on the Web Server tab, you’ll need to set a document root. This is where all of your files are going to be for your local web server. An example of a document root is /Users/USERNAME/Sites/wordpress/.

Once you’re done editing all of the settings, hit OK to save them.

Step 3: Starting MAMP Servers & Creating The Database

To start the MAMP Apache and MySQL servers, simply click "Start Servers" from the main MAMP screen. Your MAMP servers have now been started.

Once the MAMP servers start, the MAMP start page should open in your default web browser. If not, click on "Open start page" in the MAMP window. Once that’s open, select phpMyAdmin from the webpage.

Under "Create new database", enter in a database name such as "wordpress", and press "Create." No need to choose an option for "collation" : it will automatically be assigned by MySQL when the database tables are created, during the WordPress installation.

Step 4: Downloading and Installing WordPress

Now it’s time to download WordPress. Once you’ve downloaded and unzipped the WordPress download, open up the "wordpress" folder. Click and drag all of the files from the wordpress folder to your MAMP document root (I use /Users/USERNAME/Sites/wordpress/).

Others with the default MAMP install should rename and drag the folder to the htdocs folder, located under /Applications/MAMP. Then in the browser, go to localhost:port/folder_renamed to run the install. For example, in the default MAMP install, if the folder was renamed wordpresstest, go to localhost:8888/wordpresstest.

Lastly, we’ve got to run WordPress’ famous 5-minute installation. Visit your local site (localhost:port or localhost:port/wordpress), and enter the following information into the database setup form:

Note that the default Database Name is "Wordpress" and that you will need to change the Database Name to the name you entered into PHP Admin (in this case, "wordpresstest"). If you have multiple WordPress sites on your local machine, each of which is using its own database, you will need to make the Database Name in the WordPress configuration consistent with your second (or third or fourth) Database Name.

Once that’s complete, enter a blog name and email address, and you’re ready to use WordPress on your Mac.

WordPress error establishing a database connection mac os x

i am very beginner in wordpress and want to learn it and the first step was fail 🙁 i tried to install it on localhost (xampp) and this error "Error establishing a database connection" kept shows

  1. install xampp-osx-5.6.30.
  2. turn on mysql database and apache server.
  3. go to phpmyadmin and add new database name it "wp".
  4. download wordpress 4.7.2
  5. copy the wordpress folder to htdocs then rename it to wp.
  6. go to wp-sample-config rename it to wp-config change the database name to wp, database username to root and database password empty ”.
  7. in the browser localhost/wp/wp-admin/install.php

then the error shows

i tried to add new user in the phpmyadmin and change the wp-config i tried to change the database host from localhost to in wp-config i tried to unistall xampp twice i tried different program mamp nothing helped

my os x version is os x yosemite 10.10.5 should i change any sittings in my computer? is there any programs that i may install it causes the problem? what can i do?

WordPress error establishing a database connection mac os x

I am really confused by the wordpress installation. The wp_config file has the root username and password for my instance of mysql (localhost) and I have created a blank database called ‘wordpress’ (I am not sure whether I am supposed to have a database created to begin with).

When I go to http://localhost/wordpress/ I get an ‘Error establishing a database connection’ message. Am I suppose to have a database called ‘wordpress’ to begin with?

These are my credentials from the config file:

Basically, on a default installation on a Mac you have to connect to instead of localhost . So if you change the following it should work.

With WordPress you should have a database setup already (no tables, just the database).

So the first option should be the database name. If you’re on shared hosting there might be a prefix before the database name.

Then the user of the database (which should be set up when setting up the database).

Then the password of that user.

Then, finally, the host is usually localhost , but if you’re on shared hosting it could be different. You’d have to check your hosting providers docs to be sure.

Apache Friends Support Forum

Error establishing a database connection: XAMPP WordPress

Error establishing a database connection: XAMPP WordPress

by sgollor » 22. February 2017 23:49

Good day Everyone,

Please I’d be delighted if I can get some help with this. There’s a lot of documentation on this but my troubleshooting has failed. Im sorry if this is a repetition. I installed XAMPP for windows which works fine but it is not working for my MAC OS Sierra.

My XAMPP version is 5.6.30-0
My servers are running.

This is my wp-config.php details:

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

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

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

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

The user "admin" is a new user I created just for the "WP" database in phpMyAdmin.

I tried to go to http://localhost/wp/ but get the error "Error establishing a database connection""

I’ve also tried adding images to this post but I cannot get my head around it just yet, hopefully with time.

I want to keep this short for now but I will give more information as it may be required.

Thank you very much.

Re: Error establishing a database connection: XAMPP WordPres

by sgollor » 23. February 2017 10:39

The issue has been fixed.

I replaced curly quoted with single quotes. This is the new config.php file.

Code: Select all /** MySQL database username */
define(‘DB_USER’, ‘admin’);

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

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

WordPress MU

The MU forums have moved to WordPress.org

Error establishing a database connection (20 posts)

Posted 11 years ago #

I’ve seen this error posted a few times, but never a clear resolution.

I am running my own server at home (IIS, port 8080, mySQL, PHP5)I’ve had this config set up before and working fine with WordPress but I recently formatted my server and started over for various reasons. Now it seems I can not get wordpress to connect to my mySQL server.

mySQL is up and running. This I know. I can connect to it via a GUI interface using the wordpress log and get to the wordpress database without problem.

When I try to load the wordpress pages though I get the following error:

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.

YES I am using the proper login and pass. I have even tried the root login and pass to no avail. I have tried "localhost", I have tried the internal IP (192.168.1.XXX) and I have tried the external IP, and even the domain name for my server. Nothing works.

WPMu isn’t going to work on port 8080. Just for reference. It’s hard coded for port 80.

May want to try using localhost.localdomain instead. I know that has come up for a solution in the past.

Anyhting in the error logs for mysql?

I really which a real error would kick out with mysql errors. *sigh*

Although this topic has been discussed ad-nauseum on various forums, I can’t seem to find a satisfactory solution! Any help would be appreciated.

I can assure you that I have the right username and password in mysql! For example:

mysql> select * from user_privileges
| ‘wordpress’@’localhost’ | NULL | USAGE | NO |

: mysql -h localhost -u wordpress -p wordpress
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32 to server version: 5.0.27

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

See – I can manually connect to the database with the right password.

And I also have the same password in wp-config.php:

define(‘DB_NAME’, ‘wordpress’);
define(‘DB_USER’, ‘wordpress’);
define(‘DB_PASSWORD’, my password);
define(‘DB_HOST’, ‘localhost’);

And yet, when I run wp-admin/install.php, I get the above error!

Thanks for any light any of you can shed on this.

Check with your host. Depending on the software running the box, it may be adding something like your username to teh name of the mysql-user or mysql-database. Since you’re at a command prompt as the user, you may not need it there so it works then but not when the webserver is handling the connection.

Also make sure that the mysql-user has access to the database as I know CPanel requires that.

Posted 11 years ago #

I was just confronted with this same problem on one machine, although an *identical* installation on another *identical* machine worked just fine. I was able to work around the problem by changing (‘DB_HOST’, ‘localhost’) to (‘DB_HOST’, ‘’). Very weird, especially since /etc/hosts says " localhost.localdomain localhost".

FWIW, ipv6 is enabled on the machine that’s misbehaving but not on the one that works as it should. On the problem machine, mysql only binds on v4 addresses and does not listen on v6. I have no idea if this is relevant, it just happens to be the only difference between the two machines.

Posted 11 years ago #

It may seem kinda trivial, but it may have needed: localhost localhost.localdomain

If the only difference is literally the option for v6, then that would likely be the place to start looking if the modification to /etc/hosts above didn’t correct it.

For me, if there isn’t a reason for v6, I turn it off.

Stupid aside since it just popped into my head. I wonder what will happen when we get to v8? 🙂

Posted 11 years ago #

If past history is any indication, like with v6, nothing. lol

Posted 9 years ago #

I was trying to develop on a local machine (Mac OS X 10.5), and changing the localhost variable to fixed this. This needs to be documented better?

I wonder if it’s because of having virtual hosts enabled?

Hi, I also have this problem.

After I get this message:

Installation Finished!

Your WordPress µ site has been configured.

You can log in using the username "admin" and password 7531caa1ca0d

Directory Permissions

Please remember to reset the permissions on the following directories:

You can probably use the following command to fix the permissions but check with your host if it doubt:
chmod 755 /home/a5071943/public_html /home/a5071943/public_html/wp-content/

Further reading

If you run into problems, please search the WordPress µ Forums where you will most likely find a solution. Please don’t post there before searching. It’s not polite.
There is also the WordPress µ Trac. That’s our bug tracker.
Thanks for installing WordPress µ!

wpmu version: 2.7

I immediately reset the permissions in the directories mentioned above to 755, and when I clicked the "Log In" button at the Installation page, it shows "Error establishing database connection"

This is my third attempt in installing the WordPress MU, and this always happens even if I already reset the permissions. What is wrong with this and what can I do about it? Thank you.

Posted 9 years ago #

Leave a Reply

Your email address will not be published. Required fields are marked *