Database Environment Set up(Windows ver.) MySQL Configuration

Once installation of XAMPP is complete, database MySQL is also ready to use.

When you create a system where a database is used, you need to set up MySQL after having installed XAMPP.

Setting Up Character Set

First, set up character set.

Select “mysql” -> “bin” (under the xampp folder by default) and open the file “my.ini” in memo pad, etc.

mysql_char-1-en

When the file is opened, make modifications as below around the 155th line.
If you modify some other lines by mistake, there is possibility that MySQL does not work. So, it is recommended that you copy the file “my.ini” and save it for backup.

(Before modification)
#character_set_server=utf8
#skip-character-set-client-handshake

(After modification)
character_set_server=utf8
skip-character-set-client-handshake

That’s all for setting up character set.


Booting MySQL

Now let’s start MySQL!

First, open the folder where XAMPP is installed (i.e. xampp folder directly under C drive by default).
Double-click the file “xampp-control.exe”, which is at the bottom of xampp folder.

mysql-1-en

It would be convenient if you create a desktop shortcut icon for this exe file.

To create a shortcut icon, right-click the exe file “xampp-control.exe” and select “Create shortcut”.
Once a shortcut icon is created, move it to Desktop.

mysql-2-en

A panel window is displayed as below. Click “Start” buttons on the right of “Apache” and “MySQL”.

mysql-3-en

A warning screen as below may be displayed due to firewall functions. In such case, click “Allow access” button.

mysql-4-en

If Apache and MySQL are shown as below, start-up is complete.

mysql-5-en


Operation of MySQL

Now that MySQL has been booted, log in to MySQL and try some operations.

At the same time as you press Windows key, press R key.
“Run” screen is displayed on screen. Enter “cmd” in “Open” field and click “OK” button.

mysql-10-en

Then you will see the screen as below called “command prompt”.
You will run MySQL by using this “command prompt”.

mysql-11-en

Then, follow the below procedures and log in to MySQL.
To begin with, enter the command below after ‘ > ‘ which is shown at the end on command prompt screen, and click “Enter” key.

cd C:\xampp\mysql\bin

“cd” is the command to specify which directory to move to.
The above description specifies “bin” folder under “mysql” folder under “xampp” folder under C Drive.

If you have successfully moved to the directory, the command prompt screen will be as below.

mysql-12-en

Next, enter the command to log in to MySQL and click “Enter” key.

mysql -u root

Once you have successfully logged in to MySQL, the command prompt screen will be as below.

mysql-13-en

Enter an SQL statement after ‘mysql > ‘ to manipulate data in a database.

Data management unit in MySQL is a database.
For example, when you collectively manage data in a book management system, you would need to store all the tables related to the book management system in the same “database”.

To begin with, let’s take a look at what databases are currently available in the MySQL environment.
Enter the command as below and click “Enter” key.

mysql > show databases;

Then you will see the list of sample databases that are available from the beginning.

mysql-14-en

Create a new database for your learning.
‘techfun’ is the name of a database. You can specify another name, of course.

mysql > create database techfun;

Let’s check if the specified database has been really created by running the command below.

mysql > show databases;

Do you see the database ‘techfun’ shown on screen?

In StudySmile or Tech Fun.jp, please use the database ‘techfun’.

mysql-15-en

A MySQL database is like a box to manage each collective data.
When you use MySQL, you always need to select which database to be used.
Select the database that you have just created.
You can select the database to use by running the command below.

mysql > use database_name;

If you see the message “Database changed” on command prompt screen, it indicates that the specified database has been selected with no problem.

How to enter a long SQL statement.

When you enter commands on command prompt, it is possible to insert line feeds in the middle of a statement.
For example, if you enter ‘mysql > show databases’ without a ” ; ” at the end and press “Enter” key, command prompt screen will be as below.

mysql > show databases
     -> 

This means that one statement still continues.
When you enter ” ; ” after an arrow and press “Enter” key, the command runs.
This function allows you to divide a long SQL statement into several lines by inserting line feeds. You will get the same execution result from this way of writing a command.

mysql > show
     -> databases
     -> ;

That’s all for setting up MySQL.


If you are a learner in StudySmile or Tech Fun.jp, please move on to Test Data Creation.