Recent Posts

How to Create Database of MariaDB in XAMPP

GOAL

Today’s goal is create database with MariaDB.

Environment

Windows10
XAMPP 7.4.10

If you don’t have XAMPP, please install it first according to “Installation of XAMPP“. And If you’ll use MariaDB in a production environment, make it secure by setting password according to “How To Set MySQL Password in XAMPP“.

Method

1. Open phpMyAdmin

Start XAMPP Control Panel and run Apache and MariaDB.

Access localhost/phpmyadmin/ or click Admin button of MySQL.

(more…)

How To Set MySQL Password in XAMPP

GOAL

To set MySQL password in XAMPP to make it secure.

Environment

Windows10
XAMPP 7.4.10

If you don’t have XAMPP, please install it first according to “Installation of XAMPP“.

XAMPP security

Please refer to “Is XAMPP production ready?” in Windows Frequently Asked Questions for information. Though it contains some old contents, but it says why default XAMPP shouldn’t be used in a production environment.

Method

1. Run Apache and MySQL

Start XAMPP Control Panel and run Apache and MySQL.

2. Access phpMyAdmin and change password

Access localhost/phpmyadmin with your browser. And click “User accounts”.

Click “Edit privileges” for root@localhost.

Click “Change password”.

Input your password. You can generate highly safe password with Generate button. And click “Go” button.

Close phpMyAdmin.

*An error will occur when accessing phpMyAdmin now because phpMyAdmin doesn’t know the password.

3. Change config.inc.php of phpMyAdmin

Open xampp\phpMyAdmin\config.inc.php and change the value of $cfg[‘Servers’][$i][‘password’].

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';  //input the password here

Save the file and close it.

Confirmation

Open the shell.

And input command “mysql -h localhost -u root -p” and the password you defined.

# mysql -h localhost -u root -p
Enter password:  <input password here>

Confirm that MariaDB is connected.

Input “quit” to quit MySQL.

And confirm that you can access localhost/phpmyadmin.

Next?

How to Create Database of MariaDB in XAMPP

How To Run PHP in XAMPP

I installed XAMPP in Installation of XAMPP. Today, I’ll use XAMPP as a test environment for PHP.

GOAL

To setup XAMPP and start PHP development in XAMPP.

How to start XAMPP

Be sure that the started module is stopped before quitting the control panel.

Method 1 Use xampp/xampp-control.exe

Right-click and run as administrator “xampp/xampp-control.exe” or “XAMPP Control Panel” in start menu.

Click “Start” buttons on the control panel.

If you add modules as a service, the check box is checked.
*You can’t see whether the check box is checked if you run the control panel as a non-administrator.

In this article below, a situation in which all modules are not registered as a service is supposed.

Click “Start” to start Apache and access localhost to confirm that apache is running.

Open browser and input “localhost”
The index page of XAMPP

Method 2 Use batch file

Use batch files in xampp\ directory to start each application individually.

xampp\xampp_start.exe
xampp\xampp_stop.exe
xampp\apache_start.bat
xampp\apache_stop.bat
mysql_start.bat, mercury_start.bat and filezilla_start.bat

Run your php program

The directory “xampp\htdocs” is document root that is assigned to localhost. So you can run your php program by putting the php file here.

Open xampp\htdocs\index.php and you can see the program to redirect users to localhost/dashboard by using header() function.

<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/dashboard/');
	exit;
?>

1. Create “test” directory in xampp\htdocs.

2. Create PHP files

Create 2 PHP files in the “test” directory, index.php to post input data and posted.php to get and display the input data.

xampp\htdocs\test\index.php

Use POST method to send the message.

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>test</title>
</head>
<body>
	<form action="posted.php" method="POST">
		<label>Input message:</label>
		<input type="text" name="message" /> <input type="submit" value="Submit!" />
	</form>
</body>
</html>

xampp\htdocs\test\posted.php

Get the posted data by using $_POST[<name>].

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>posted</title>
</head>
<body>
	<p>Message "<?php echo $_POST["message"] ?> " is posted!</p>
</form>
</body>
</html>

3. Change the redirect destination URL in xampp\htdocs\index.php

xampp\htdocs\index.php

<?php
	if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
		$uri = 'https://';
	} else {
		$uri = 'http://';
	}
	$uri .= $_SERVER['HTTP_HOST'];
	header('Location: '.$uri.'/test/');  // Change here!
	exit;
?>

4. Access localhost

Access localhost and the page is redirected to localhost/test/. Input any message you like and press submit button.

The posted page will be displayed and you can see the message you input.

Categories

AfterEffects Algorithm Artificial Intelligence Blender C++ Computer Graphics Computer Science Daily Life DataAnalytics Event Game ImageProcessing JavaScript Kotlin mathematics Maya PHP Python SoftwareEngineering Tips Today's paper Tools TroubleShooting Unity Visual Sudio Web Windows WordPress 未分類