MySQL and phpMyAdmin – XAMPP

Hi all,

Today I going to show on how to access MySQL and phpMyAdmin using XAMPP.

Step 1: Start the MySQL

XAMPP only offers MySQL (Database Server) & Apache (Webserver) in one setup and you can manage them with the xampp starter.

After the successful installation navigate to your xampp folder and execute the xampp-control.exe

Press the start Button at the mysql row.

Step 2: Open the phpMyAdmin

In order to check whether the mySQL is work or not,  Open your browser and enter http://localhost/phpmyadmin. This will bring you to the MySQL setup page:

Step 3: Set the password of your MySQL

It is better to set the password of your MySQL (Database server). To do that, select User accounts. You can choose the user account that you want to set the password. The default is:

Username: root

Hostname: localhost

Go to Edit privileges and click change password tab. Select Password. Set your password. In this case, I set to “1234”. Then click the button GO and the right.

Step 4: Set the password in config.ini.php

When you set the password in mySQL through the phpMyAdmin, you also need to set the password in a file named config.ini.php. The file is located at C:\xampp\phpMyAdmin

Then, open the file in Sublime Text 3. Set your password such as “1234” at line 21 as shown below.

We going to used this password for the next tutorial.

Step 5: Create a new user

For our own safety, we need to create our user so that the hacker cannot access our account. For example, like below.

If you got an error, go to SQL tab, and type:

FLUSH PRIVILEGES;

Click button Go.

Step 6: Test the connection

In order to test the user that we created, let create a php file name “connection_mysql.php“. Write a coding below:

<?php

$servername = "localhost";
$username = "shaharil";
$password = "1234";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if($conn -> connect_error)
{
die("Connection failed:" . $conn->connect_error);

}
print("Connection successfully");

?>

The picture is shown below:

Lastly, go to your browser and open the link of connection_mysql.php.

http://localhost/ArinProject/PHP_MYSQL/connection_mysql.php

You will see the result like below : “Connection successfully”

 

DONE !!!!