• Resolved ntms2020

    (@ntms2020)


    Hi

    I try to run wordpress on my macbook, and keep getting a error establishing a database connection. I try to write database name, username, password, and leave database host as localhost and leave table prefix as wp_ and seems can’t make connection to database. When I install mamp didn’t give me any error. after that I start the server and tab the ‘Open WebStart page’ and it open ‘http://localhost:8888/MAMP/?language=English’ from here I type http://localhost:8888/wordpress and it open ‘http://localhost:8888/wordpress/wp-admin/setup-config.php?step=0’ I try to follow screen and enter the values that ask to me as I describe above and didn’t make mysql connection. Any idea how to make it to run?

    error:

    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 127.0.0.1. This could mean your host’s database server is down.
    
    Are you sure you have the correct username and password?
    Are you sure you have typed the correct hostname?
    Are you sure 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.
    • This topic was modified 5 years, 4 months ago by ntms2020.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator t-p

    (@t-p)

    Thread Starter ntms2020

    (@ntms2020)

    Hi @t-p

    I don’t have wp-config.php and The WordPress setup process didn’t create a wp-config.php file for me based on the information I provide !!!

    Moderator t-p

    (@t-p)

    Where is wp-config.php?
    It should be in the WP root directory.

    If it wasn’t created, then create one.

    To recreate a new one, make a copy of wp-config-sample.php (which comes with the WprdPress) and add all of your database connection details. Then save the new file as wp-config.php and upload it to your WP folder.

    Editing wp-config.php: https://wordpress.org/support/article/editing-wp-config-php/

    • This reply was modified 5 years, 4 months ago by t-p.
    Thread Starter ntms2020

    (@ntms2020)

    Hi @t-p

    In follow the link and your post. I copied the wp-config-sample.php to wp-config.php and change my credentials. Than I start the server again and this time I got ‘Error establishing a database connection’ in a single line and no other error text. Here is my settings after change in wp-config.php.

    Ignore the mydbname, myusername and mypassword. I didn’t want to write my credentials.

    <?php
    /**
     * The base configuration for WordPress
     *
     * The wp-config.php creation script uses this file during the
     * installation. You don't have to use the web site, you can
     * copy this file to "wp-config.php" and fill in the values.
     *
     * This file contains the following configurations:
     *
     * * MySQL settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/Editing_wp-config.php
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define( 'DB_NAME', 'mydbname' );
    
    /** MySQL database username */
    define( 'DB_USER', 'myusername' );
    
    /** MySQL database password */
    define( 'DB_PASSWORD', 'mypassword' );
    
    /** 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', '' );
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define( 'AUTH_KEY',         'put your unique phrase here' );
    define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
    define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
    define( 'NONCE_KEY',        'put your unique phrase here' );
    define( 'AUTH_SALT',        'put your unique phrase here' );
    define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
    define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
    define( 'NONCE_SALT',       'put your unique phrase here' );
    
    /**#@-*/
    
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each
     * a unique prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix = 'wp_';
    
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     *
     * For information on other constants that can be used for debugging,
     * visit the Codex.
     *
     * @link https://codex.wordpress.org/Debugging_in_WordPress
     */
    define( 'WP_DEBUG', false );
    
    /* That's all, stop editing! Happy publishing. */
    
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
    	define( 'ABSPATH', dirname( __FILE__ ) . '/' );
    }
    
    /** Sets up WordPress vars and included files. */
    require_once( ABSPATH . 'wp-settings.php' );
    Thread Starter ntms2020

    (@ntms2020)

    Bit more info:

    My MAMP shows
    Apache port: 8888
    Nginx Port: 8888
    MySQL Port: 8889

    and uses PHP standart version 7.3.8 and I am using Apache as web server and mysql version shows 5.7.26

    In tools when I press Check MySQL database didn’t show any error at all. I am running these on macOS Catalina 10.15.2

    Moderator t-p

    (@t-p)

    Please review the documentations of your system.

    Also review this WP installation guide: https://wordpress.org/support/article/how-to-install-wordpress/

    Thread Starter ntms2020

    (@ntms2020)

    Thanks @t-p after searching I find that I should open phpadmin and create a database first. And now is working. Kind thanks

    Moderator t-p

    (@t-p)

    Glad its sorted 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.