• Hi there, I’m trying to manually install wordpress to test an offline site using MAMP. I follow these steps but the database just wont accept the password.

    -Install MAMP

    Start Apache and SQL servers

    Login to MAMP on a browser and open phpadmin. Create a database called ‘wordpress’

    -Download wordpress and copy it into a folder called ‘wordpress’ in C:\MAMP\htdocs

    -Open browser and go to https://localhost:8888/wordpress

    -The WordPress opening screen appears.

    -Database name is wordpress, user is root and password is root. Database is localhost and table prefix is wp_. Click submit.

    -Get Error establishing a database connection

Viewing 5 replies - 1 through 5 (of 5 total)
  • Tried without typing a password (means left the field empty)?

    You have probably entered the host incorrectly. According to their instructions, the port is a different one: https://documentation.mamp.info/en/MAMP-Windows/How-Tos/WordPress/

    Ritik Tiwari

    (@theritiktiwari)

    Hey @orchardpost, you should try the following steps to troubleshoot the issue:

    1. Verify MAMP MySQL Settings: By default, MAMP uses root as both the username and password for MySQL, but you need to confirm these settings:

    • Open MAMP and go to Preferences > Ports:
      • Ensure the MySQL port is set to 8889 (default for MAMP).
    • Open phpMyAdmin by navigating to https://localhost:8888/phpMyAdmin in your browser:
      • Try logging into phpMyAdmin using the following credentials:
        • Username: root
        • Password: root
      If you can log into phpMyAdmin, then the MySQL server is running, and the credentials are correct.

    2. Check the MySQL Port: MAMP uses a non-standard port for MySQL, which might be causing the connection issue. By default, it’s 8889, not the usual 3306.

    • When setting up WordPress, the Database Host should be localhost:8889 instead of just localhost.

    3. Edit the wp-config.php File Manually: During the WordPress setup process, you can configure the wp-config.php file yourself to ensure the database connection details are correct.

    • After getting the error, WordPress will ask you to manually configure the wp-config.php file.
    • Navigate to the folder where you installed WordPress (C:\MAMP\htdocs\wordpress).
    • Open the wp-config-sample.php file in a text editor and save it as wp-config.php after editing.Modify the following lines to match your MAMP configuration:
    /** The name of the database for WordPress */
    define( 'DB_NAME', 'wordpress' );

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

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

    /** MySQL hostname */
    define( 'DB_HOST', 'localhost:8889' );
    • Make sure the DB_HOST is set to localhost:8889 (or whichever port your MAMP MySQL server is using).

    4. Test Database Connection: You can create a simple PHP script to test whether WordPress can connect to the database. Create a file called dbtest.php in your C:\MAMP\htdocs\wordpress folder with the following code:

    <?php
    $servername = 'localhost:8889';
    $username = 'root';
    $password = 'root';

    // Create connection
    $conn = new mysqli( $servername, $username, $password );

    // Check connection
    if ( $conn->connect_error ) {
    die( 'Connection failed: ' . $conn->connect_error );
    }
    echo 'Connected successfully';
    ?>
    • Go to your browser and visit https://localhost:8888/wordpress/dbtest.php.
    • If it shows “Connected successfully”, then the database connection is fine. If not, there is still an issue with the database settings (likely related to the port or credentials).
    Amit Dholiya

    (@amitdholiya1990)

    It sounds like you’re on the right track, but the “Error establishing a database connection” typically indicates an issue with the database credentials or configuration. Here are a few troubleshooting steps to help you resolve this:

    Verify Database Credentials:

    • Double-check the database name (it should be wordpress), username (usually root), and password (usually root).
    • In some cases, the password might be blank (empty), so try leaving the password field empty.
    webpediapro

    (@webpediapro)

    Here are some troubleshooting steps to help:

    1. Check MAMP’s MySQL username/password: By default, MAMP uses “root” for both the username and password, but you can double-check this in MAMP settings:
      • Open MAMP.
      • Go to Preferences > Ports and ensure that the Apache Port is 8888 and the MySQL Port is set to 3306 (which should be the default).
      • Check the User and Password under the MySQL tab. It should say root for both. If this is different, update it in the WordPress installation screen.
    2. Ensure correct server settings:
      • Make sure the Database Host is localhost, which you already set.
      • Ensure you haven’t mistakenly added any spaces or typos in the database name, username, or password fields.
    3. Check the database in phpMyAdmin:
      • Log in to phpMyAdmin via localhost:8888/phpmyadmin.
      • Double-check that the database wordpress has been created correctly. Sometimes it might help to delete and recreate the database.
    4. Database connection in wp-config.php:
      • If the error persists, you can manually edit the wp-config.php file located in the WordPress folder.
      • Open wp-config.php and verify that the following settings match your environment:phpCopy codedefine('DB_NAME', 'wordpress'); define('DB_USER', 'root'); define('DB_PASSWORD', 'root'); define('DB_HOST', 'localhost');
      • If DB_HOST uses a non-default port, it should be localhost:3306 (MAMP’s default MySQL port) or the correct port number for your setup.
    5. Check MAMP MySQL service:
      • Ensure that MySQL is running in MAMP. Go to the MAMP control panel and ensure both Apache and MySQL servers are running.

    If you follow these steps and still encounter issues, let me know, and we can dive deeper!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.