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).