Detailed XAMPP tutorial covering common tasks, error troubleshooting, port configuration, backup/restore procedures, security essentials, and useful tools for local web development.
XAMPP Notes —Part 3 of 3
Page 1
Prepared By: Jaydeep Kale
XAMPP
Part 3 of 3: Common Tasks, Errors & Solutions, Ports, Backup/Restore, Security &
Useful Tools
2.
XAMPP Notes —Part 3 of 3
Page 2
Prepared By: Jaydeep Kale
Contents of Part 3
• 14. Common Tasks
• 15. Common Errors and Solutions
• 16. Changing Default Ports
• 17. Backup and Restore
• 18. Security Basics
• 19. Useful XAMPP Tools
3.
XAMPP Notes —Part 3 of 3
Page 3
Prepared By: Jaydeep Kale
14. Common Tasks
Creating a New Project
1. Open the htdocs folder inside the XAMPP installation directory.
2. Create a new folder and name it after your project (no spaces or special characters).
3. Create your PHP/HTML/CSS files inside this folder, starting with an index.php or index.html as the entry
point.
4. Ensure Apache (and MySQL, if the project uses a database) is running from the Control Panel.
5. Open a browser and visit http://localhost/yourprojectname/ to view the project.
Importing an Existing Project
1. Copy the entire project folder (containing all PHP/HTML/CSS/JS files) into the htdocs folder.
2. If the project uses a database, open phpMyAdmin and create a new database with the name expected by the
project's configuration file.
3. Import the project's provided .sql file into that database using phpMyAdmin's Import tab (see Topic 11).
4. Locate the project's database configuration file (often named config.php, db.php, or similar) and update the
database name, username, and password to match your local setup.
5. Start Apache and MySQL, then open the project in a browser via http://localhost/projectfolder/ to verify it
works.
Connecting PHP with MySQL
PHP connects to the MySQL/MariaDB server using a database extension such as mysqli or PDO. A basic
connection using mysqli looks like this:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mydatabase";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
By default, XAMPP's MySQL/MariaDB uses the username 'root' with a blank (empty) password, which is why
$password is left as an empty string in local development.
4.
XAMPP Notes —Part 3 of 3
Page 4
Prepared By: Jaydeep Kale
Testing Database Connection
1. Save the connection script above as a file, e.g., connect.php, inside your project folder in htdocs.
2. Make sure Apache and MySQL are both running.
3. Open the browser and navigate to http://localhost/yourproject/connect.php
4. If the page displays 'Connected successfully', the connection to the database is working correctly.
5. If an error message such as 'Connection failed' appears, check that the database name, username, and
password in the script match what's set up in phpMyAdmin, and confirm MySQL is running.
5.
XAMPP Notes —Part 3 of 3
Page 5
Prepared By: Jaydeep Kale
15. Common Errors and Solutions
Apache Won't Start
• Cause: Port 80 (or 443) is already used by another application.
• Solution: Check the Apache log via the Control Panel's Logs button, identify the conflicting port, and either
close the conflicting application or change Apache's port (see Topic 16).
MySQL Won't Start
• Cause: Port 3306 is occupied by another MySQL instance or service, or the data folder has become
corrupted.
• Solution: Close any other running MySQL service, check the MySQL error log for specific messages, or
change MySQL's port as described in Topic 16.
Port 80 Conflict
This happens when another program is already listening on port 80 when Apache tries to start. Common culprits
include Skype (older versions), IIS (Internet Information Services on Windows), VMware services, or another
local web server such as WAMP or a previously running Apache instance.
Port 3306 Conflict
This occurs when another MySQL/MariaDB installation (or another XAMPP-like stack) is already running and
occupying port 3306. Only one MySQL service can use a given port at a time on the same machine.
Skype/IIS Conflict
Older versions of Skype used to listen on ports 80 and 443 for incoming connections, directly conflicting with
Apache. Similarly, Windows' built-in IIS (Internet Information Services) web server also defaults to port 80. To
resolve either conflict:
1. In Skype, go to Tools/Settings → Advanced → Connection, and uncheck 'Use port 80 and 443 as
alternatives'.
2. For IIS, open 'Turn Windows features on or off' and disable Internet Information Services, or stop the
'World Wide Web Publishing Service' from Windows Services.
3. Restart the computer, then try starting Apache again from the XAMPP Control Panel.
Missing DLL Errors
• Cause: A required system library (such as msvcr110.dll or vcruntime140.dll) is missing, usually because the
Microsoft Visual C++ Redistributable package is not installed.
6.
XAMPP Notes —Part 3 of 3
Page 6
Prepared By: Jaydeep Kale
• Solution: Download and install the Microsoft Visual C++ Redistributable package matching your XAMPP
version's requirements (usually mentioned on the Apache Friends FAQ page), then restart the computer.
Access Denied in MySQL
• Cause: The username/password used in a PHP script or phpMyAdmin login does not match the credentials
configured in MySQL, or the root account has been given a password that the application isn't using.
• Solution: Verify the username and password in your connection script; if you previously set a root password
and forgot it, phpMyAdmin's User Accounts tab (or the mysqladmin command-line tool) can be used to
reset it.
7.
XAMPP Notes —Part 3 of 3
Page 7
Prepared By: Jaydeep Kale
16. Changing Default Ports
Change Apache Port
1. Open the XAMPP Control Panel and click the 'Config' button next to Apache, then select 'httpd.conf'.
2. Find the line that reads Listen 80 and change 80 to a new port number, e.g., Listen 8080.
3. Find the corresponding line ServerName localhost:80 and update it to match, e.g., ServerName
localhost:8080.
4. Save the file and close the editor.
5. Restart Apache from the Control Panel (Stop, then Start) for the change to take effect.
Change MySQL Port
1. Click the 'Config' button next to MySQL in the Control Panel and open 'my.ini'.
2. Locate the line Port=3306 under the [mysqld] section and change it to a new port, e.g., Port=3307.
3. Also update the Port= value under the [client] section (if present) to keep both in sync.
4. Save the file and restart MySQL from the Control Panel.
5. Update any PHP scripts' database connection code to reference the new port if it is no longer the MySQL
default.
Accessing Using New Ports
Once Apache's port is changed, the port number must be included in the URL, since browsers assume port 80 by
default for HTTP:
http://localhost:8080/yourproject/
Similarly, if the MySQL port was changed, database connection code must specify the new port explicitly, for
example when using mysqli:
$conn = new mysqli("localhost:3307", "root", "", "mydatabase");
8.
XAMPP Notes —Part 3 of 3
Page 8
Prepared By: Jaydeep Kale
17. Backup and Restore
Database Backup
1. Open phpMyAdmin and select the database you want to back up from the left panel.
2. Click the 'Export' tab at the top.
3. Choose the 'Quick' export method (recommended for a simple, complete backup) with format set to 'SQL'.
4. Click the 'Go' button; phpMyAdmin generates a .sql file containing the database structure and data, which
downloads to your computer.
5. Store this .sql file safely (e.g., in cloud storage or an external drive) as your backup.
Import and Export SQL
Export creates a downloadable .sql file representing the current state of a database (its tables and data). Import
loads a .sql file's contents into a database, recreating the tables and inserting the data. The Import process is the
same as described in Topic 11: select the target database, open the Import tab, choose the file, and click Go.
Copying Projects
Because a XAMPP project consists of files stored in htdocs plus data stored in the MySQL/MariaDB database,
copying a project fully to another computer requires two parts:
• Copy the entire project folder from htdocs to the same location on the new machine.
• Export the project's database using phpMyAdmin (as above) and import that .sql file into the new machine's
phpMyAdmin under a database with the same name expected by the project's configuration file.
Restoring XAMPP Projects
1. Install XAMPP on the new/target computer if not already installed.
2. Copy the project folder into the new installation's htdocs directory.
3. Start Apache and MySQL from the Control Panel.
4. Open phpMyAdmin and create a new database with the exact name the project expects.
5. Import the previously exported .sql backup file into this new database.
6. Update the project's database configuration file with the correct credentials if they differ from the original
machine.
7. Open http://localhost/projectfolder/ in a browser to confirm the project is restored and working.
9.
XAMPP Notes —Part 3 of 3
Page 9
Prepared By: Jaydeep Kale
18. Security Basics
Default Passwords
By default, XAMPP's MySQL/MariaDB root user has no password (a blank password), and phpMyAdmin allows
login as root without requiring one. This is convenient for local development but is a serious security risk if the
machine is ever exposed to a network or the internet, since anyone could gain full access to all databases.
Restricting phpMyAdmin
• Set a strong password for the MySQL root account via phpMyAdmin's 'User accounts' tab, and update any
project scripts to use the new password.
• Edit the phpMyAdmin configuration (config.inc.php) to require authentication rather than allowing
automatic root login.
• Restrict access to phpMyAdmin by IP address in Apache's configuration (e.g., in httpd-xampp.conf) so that
only localhost/127.0.0.1 can reach it, blocking outside network access.
• Avoid exposing the XAMPP machine directly to the public internet unless it has been properly hardened;
XAMPP is designed primarily for local development, not production hosting.
Production vs Development Environment
Development (XAMPP default) Production (Live Server)
Errors are often displayed directly in the browser for
debugging.
Errors are logged privately and hidden from visitors for
security.
Root database account has no password. Database accounts use strong, unique passwords with
limited privileges.
phpMyAdmin is easily accessible without strict
authentication.
Administrative tools are protected, restricted, or disabled
entirely.
Runs on a personal computer, not exposed to the
internet.
Runs on a dedicated, secured server exposed to the
internet.
Focus is on convenience and speed of development. Focus is on security, stability, and performance under
real traffic.
10.
XAMPP Notes —Part 3 of 3
Page 10
Prepared By: Jaydeep Kale
19. Useful XAMPP Tools
phpinfo()
phpinfo() is a built-in PHP function that outputs a detailed page showing the current PHP configuration —
including the PHP version, loaded extensions, php.ini settings, and server environment variables. It is extremely
useful for confirming what PHP version and modules are active.
<?php
phpinfo();
?>
Save this code as a .php file inside htdocs and open it in the browser (e.g., http://localhost/phpinfo.php) to view
the full configuration report.
Logs
Log files record what has been happening inside Apache and MySQL, including startup messages, warnings, and
errors. They are the first place to check when a service won't start or a page behaves unexpectedly.
• Apache logs: xampp/apache/logs/error.log and access.log
• MySQL logs: xampp/mysql/data/mysql_error.log
• Logs can also be opened quickly using the 'Logs' button in the Control Panel next to each service.
Shell
The XAMPP Control Panel includes a 'Shell' button that opens a command-line window with its working
directory and environment already set to the XAMPP installation folder. This makes it convenient to run
command-line tools such as php, mysql, or composer without manually configuring system PATH variables.
Netstat
Netstat is a command-line utility (built into Windows, Linux, and macOS) used to check which ports are currently
in use on the system — extremely helpful for diagnosing port conflicts described in Topic 15.
1. Open Command Prompt (Windows) or Terminal (Linux/macOS).
2. Run the following command to see which process is using port 80:
netstat -ano | findstr :80
3. Note the Process ID (PID) shown in the last column of the result.
4. Open Task Manager (Windows), go to the 'Details' tab, find the matching PID, and identify which
application is using that port.
5. Close that application, or change XAMPP's port instead, as covered in Topic 16.
11.
XAMPP Notes —Part 3 of 3
Page 11
Prepared By: Jaydeep Kale
Explorer
The Control Panel's 'Explorer' button opens the XAMPP installation folder directly in the system's file manager
(e.g., Windows Explorer), giving quick access to htdocs, configuration files, and logs without manually
navigating through the file system.