Guides

How To Install WordPress On XAMPP (Localhost Guide)

How to install WordPress on XAMPP in five steps, with the database details for localhost

XAMPP is a free package that turns your own computer into a small web server, so you can build and test a WordPress site without paying for hosting. But the setup has a few traps, and one wrong detail stops the installer with an error. If you want to install WordPress on XAMPP and keep getting stuck, this article will help you.

We are here to help you set it up step by step and fix the errors that stop most people. This guide is based on three XAMPP threads in the WordPress.org Installing WordPress forum, the official XAMPP FAQs, and our own test of the WordPress installer on a local copy of WordPress.

Related Articles

What You Need Before You Start

  • XAMPP: a free download from apachefriends.org. When we checked on November 30, 2026, XAMPP 8.4.28 included PHP 8.4.28 and MariaDB 10.11.19. That meets the WordPress recommendation of PHP 8.3 or newer and MariaDB 10.11 or newer.
  • WordPress: the latest zip file from wordpress.org/download.
  • A Windows, Mac or Linux computer where you can install software.

How We Tested It

We downloaded XAMPP 8.4.28 for macOS from the official download page. macOS's Gatekeeper check rejected the installer, because the app isn't code-signed at all, so we didn't run it. If you are on a Mac, WordPress Studio or WordPress Playground may be easier, as we explain in our WordPress installation guide.

For the WordPress side, we put a copy of WordPress 7.1.4 in a wordpress folder on our computer, just like htdocs\wordpress in XAMPP. Then we ran it with PHP 8.4 and submitted the installer's database form with XAMPP's default details. No database server was running, so it stopped at the connection error shown below. The XAMPP steps below follow XAMPP's own FAQs.

Step 1: Install XAMPP

First, download the installer for your system from the XAMPP download page and run it. On Windows, install it to C:\xampp, not inside C:\Program Files. The XAMPP Windows FAQ warns that you may not have full write access to folders under Program Files, even as an admin.

If your antivirus flags a XAMPP file, the same FAQ says this is usually a false alarm, and suggests checking the download with the free VirusTotal scanner.

Step 2: Start Apache And MySQL

Next, open the XAMPP Control Panel. On Windows, it's xampp-control.exe in your XAMPP folder. On a Mac, the app is called manager-osx. Click Start next to Apache and MySQL.

Now open http://localhost/ in your browser. If you see the XAMPP start page, the web server is working. The panel says MySQL, but XAMPP actually ships MariaDB, which uses the same commands and tools.

Step 3: Create A Database In phpMyAdmin

WordPress needs an empty database before you install it. Open http://localhost/phpmyadmin/, click New at the top of the left sidebar, type a name such as wordpress and click Create. Our guide to creating a database with phpMyAdmin shows each click.

Don't confuse the database with your site folder. In one forum thread, a user said their database was in htdocs. A forum volunteer replied that this was probably the WordPress folder, since XAMPP keeps databases in \xampp\mysql\data, and warned against touching that folder unless you know exactly what you're doing.

Step 4: Copy WordPress Into htdocs

Unzip the WordPress file. You get a folder called wordpress. Copy it into the htdocs folder inside XAMPP, which is C:\xampp\htdocs on Windows.

The folder name becomes part of your site's address, so htdocs\wordpress opens at http://localhost/wordpress/. XAMPP's FAQ recommends folder names without spaces or accented letters, so mysite is better than my site.

Step 5: Run The WordPress Installer

Open http://localhost/wordpress/ in your browser. First, choose your language and click Continue. WordPress then lists the five details it needs.

WordPress setup screen listing database name, database username, database password, database host and table prefix, with a Let's go button
The setup screen after choosing a language, on our local test copy of WordPress 7.1.4. Click Let's go! to enter your database details.

Click Let's go! and fill in the form with these XAMPP details:

  • Database Name: the name you created in Step 3, such as wordpress.
  • Username: root.
  • Password: leave it empty. XAMPP's FAQ confirms the MySQL root user has no password by default.
  • Database Host: localhost.
  • Table Prefix: keep wp_.
WordPress database connection form filled in with database name wordpress, username root, an empty password, host localhost and table prefix wp_
The database form on our test copy, filled in with XAMPP's default details. WordPress let us submit the form with the password field empty.

Click Submit, then Run the installation. Finally, enter your site title, an admin username, a strong password and your email, and click Install WordPress. Our installation guide shows these last screens.

How To Fix Common XAMPP Install Errors

"Error Establishing A Database Connection"

In our test, the database server wasn't running, and WordPress stopped with this page as soon as we clicked Submit.

WordPress installer page reading Error establishing a database connection, with a checklist and a Try Again button
What our test showed after Submit when no database server was running. In XAMPP, this usually means MySQL isn't started.

Open the XAMPP Control Panel and make sure MySQL is started, then click Try Again. If it still fails, check the details from Step 5 letter by letter. Our guide to fixing the database connection error covers the other causes.

"Cannot Select Database"

This message means WordPress reached MySQL, so the username and password are fine, but the database could not be selected. On XAMPP, this usually means the database doesn't exist yet. WordPress also asks whether the user has permission to use it, or whether the name needs a prefix. Create the database in phpMyAdmin as shown in Step 3, and make sure the name in the form matches it exactly.

Apache Won't Start

Apache uses port 80 by default, and it can't start if another program already uses that port. In one forum thread, a user moved Apache to port 85 in httpd.conf. That works, but you must then add the port to every address, such as http://localhost:85/wordpress/.

MySQL Runs On A Different Port

The same user moved MySQL from port 3306 to 3307 and kept getting the database error. A forum moderator explained that WordPress assumes port 3306 unless you add the port to the Database Host, such as localhost:3307.

On Windows, PHP uses the port you add to localhost. On a Mac or Linux, it treats localhost as a local socket file and ignores the port, according to PHP's source code. Our test on a Mac with PHP 8.4 showed this. With localhost:3307, we got the same socket error as plain localhost, while 127.0.0.1:3307 tried port 3307 as intended. So on a Mac or Linux, use 127.0.0.1:3307. If it still fails, check that your firewall isn't blocking the port, as the moderator suggested.

You See The XAMPP Page Instead Of WordPress

You opened http://localhost/, which shows XAMPP's own start page. Add your folder name to the address, such as http://localhost/wordpress/, and check that the WordPress files are inside that folder in htdocs.

Common Mistakes To Avoid

  • Using XAMPP for a live site: XAMPP's FAQ says it is built for development only, with no root password and MySQL open to the network.
  • Changing ports you don't need to change: keep Apache on 80 and MySQL on 3306 unless another program is already using them.
  • Editing files in the mysql data folder: you can damage your databases. Use phpMyAdmin instead.
  • Spaces in the folder name: XAMPP's FAQ advises against them, so use a short name like mysite.

Install WordPress On XAMPP: FAQs

Is XAMPP free?

Yes. XAMPP is a free, open-source package from Apache Friends, and WordPress itself is free too.

Does XAMPP use MySQL or MariaDB?

XAMPP has shipped MariaDB instead of MySQL since versions 5.5.30 and 5.6.14. WordPress works with both.

Can I move my XAMPP site to real hosting later?

Yes. When your site is ready, follow our guide to moving WordPress to a new host.

Final Words

To install WordPress on XAMPP, start Apache and MySQL, create the database, copy WordPress into htdocs and run the installer with root and an empty password. The errors in the forum threads and our test came from MySQL not running, a missing database, a changed port or the wrong address. Let us know in the comments which step gave you trouble.

Sources

We checked these sources for this guide on November 30, 2026:

#Beginners#Troubleshooting#WordPress