If you want to install WordPress on your local machine, you have a number of options.
I prefer to use XAMPP because it's been around for ages (so it's stable and has a lot of tutorials), I can use it on my Windows, Mac and Linux machines, and if I want to do some PHP programming outside the WordPress environment, I can.
It's also free and open source.
How to install XAMPP on Mac:
- Download the correct version of XAMPP
- Run the installer with the default options
- Launch XAMPP
- Start the services
In this tutorial, I'll be using my Mac running macOS 10.14 ("Mojave"), but the steps are the same for the other versions of Mac OSX and macOS 10.x (update: I've tested this on Catalina and it works there too).
Go to Apache Friends and download the correct version of XAMPP.
For this tutorial, I'll be using XAMPP 7.3.2 for OSX.
Open the installer.
You'll see the install window, while it gets everything ready.
Click "Open" on the warning box.
You'll probably have to put in your computer password to allow XAMPP to install.
Now we get to the setup. Click "Next" to start the process.
Just leave the default options selected. Click "Next".
XAMPP will be installed to a folder in your Applications directory.
In Windows, it will default to c:/xampp.
Learn more about Bitnami for XAMPP will be checked. Uncheck that, unless you really need to know.
Bitnami is cool, but I prefer to keep things simple. Fewer things to break.
Now everything's ready to go, click "Next".
XAMPP will install to your computer. Just let it run.
If all goes well, you'll see an installation confirmation.
Make sure Launch XAMPP is checked, then click "Finish".
You'll see the XAMPP control panel.
If you want to build a WordPress site on your local machine, you'll need to start MySQL Database and Apache Web Service.
Just click on them and click "Start".
As long as they're both green, you're good to go.
For future reference, you can access XAMPP by going to the Launchpad and clicking manager-osx. This was originally in a folder called "XAMPP", but I moved it for convenience.
Or on Windows, go to Start -> XAMPP -> XAMPP Control Panel.
What is the default XAMPP MySQL login?
The default XAMPP MySQL login is:
- Username: root
- Password is blank
That's right, there is no default password for XAMPP MySQL.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'example' ); /** MySQL database username */ define( 'DB_USER', 'root' ); /** MySQL database password */ define( 'DB_PASSWORD', '' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' );
The relevant section of your wp-config.php file will be something like:
How to change the default MySQL password for XAMPP
It's not the best idea to have a blank password for database access, even if it's only on your own computer.
It's pretty easy to change the default MySQL password.
You can use this process if you ever forget your password too.
Go to http://localhost/dashboard/
Choose the User accounts tab.
Look for the root user, then click Edit privileges.
Click Change password.
Enter a password into the Enter and Re-type fields, then click "Go".
In this instance, I just used "pass".
Final step, to make sure the password change takes effect, go to the XAMPP control, select MySQL Database and click "Restart".
If you already have any WordPress installations on the computer, be sure to update the wp-config.php file.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'example' ); /** MySQL database username */ define( 'DB_USER', 'root' ); /** MySQL database password */ define( 'DB_PASSWORD', 'pass' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' );
MySQL Error Cannot Connect: Invalid Settings
If you try to connect to phpMyAdmin right now, you'll get an error message saying MySQL cannot connect: invalid settings.
You'll also see mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO).
This happens because you changed the password for the root user.
How to fix XAMPP phpMyAdmin access denied after changing root password:
- Open /xampp/phpmyadmin/config.inc.php in a text editor
- On or about line 31, add a password inside the quotes
- Save the file and restart MySQL
Let's go through those steps. Go to /xampp/phpmyadmin/ and open config.inc.php in a text editor.
I'm using Atom for this, but any text editor will be fine.
Scroll down a little. In my version, it's line 31.
$cfg['Servers'][$i]['password'] = '';
Inside the single quotes, put the password you created for the root user.
It should look something like
$cfg['Servers'][$i]['password'] = 'pass';
Save the file.
Restart MySQL for good measure and you'll be able to login.