Windows での,XAMPP for Windows のインストール,起動,セキュリティ上の最低限の設定手順をスクリーンショット等で説明する.
XAMPP for Windows 8.2.4 は,次のソフトウェアの詰め合わせ.
【関連する外部ページ】
XAMPP の URL: https://www.apachefriends.org/jp/index.html
【目次】
このページで紹介するソフトウェア類の利用条件等は,利用者で確認すること.
※ XAMPP は学習用に適すると考えている. サーバを公開するのなら,セキュリティの設定が必要.その場合は,XAMPP を使わずに, 各ソフトを個別でインストールする方が簡単になる可能性がある.
次の手順で,XAMPP for Windows のダウンロードとインストールと動作チェックを行う.
ダウンロードが始まるので確認する.
ダウンロードした .exe ファイルを実行する
XAMPP コントロールパネルで,Apache と MySQL の右横が「Start」になっている場合には, Apache と MariaDB が起動していないという意味なので,下記の手順で,手動で起動する。
まず,Apache の右横の「Start」をクリックする
XAMPP コントロールパネルで,Apache の開始を確認する
XAMPP コントロールパネルで,Apache の右横に「Stop」と表示されることも確認する.
Apache のときと同様の操作. XAMPP コントロールパネルで,MySQL の右横の「Start」をクリックする
XAMPP コントロールパネルで,MySQL の開始を確認しておく
XAMPP コントロールパネルで,Apache の右横に「Stop」と表示されることも確認する.
コマンドプロンプトを管理者として実行: 別ページ »で説明
次のコマンドを実行
powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\xampp\mysql\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
そのために,新しく Windows のコマンドプロンプトを開き、次のコマンドを実行する.
where mysql
XAMPP コントロールパネルで, 「MySQL」の右の 「Admin」をクリック.
インストール時のTCPポート「3306」がWindowsファイヤーウォールで承認されていないという場合がある. 次の手順でWindowsファイヤーウォールを設定すると直ることがある.
データベースを作成するために,SQL の create database コマンドを使用する.
utf8 の場合の生成例
create database testdb default character set utf8 collate utf8_unicode_ci;
cp932 の場合の生成例
create database testdb default character set cp932 collate cp932_japanese_ci;
show databases;
create table order_records ( id integer primary key not null, year integer not null CHECK ( year > 2008 ), month integer not null CHECK ( month >= 1 AND month <= 12 ), day integer not null CHECK ( day >= 1 AND day <= 31 ), customer_name text not null, product_name text not null, unit_price real not null check ( unit_price > 0 ), qty integer not null default 1 check ( qty > 0 ), created_at timestamp not null default current_timestamp, updated_at timestamp not null default current_timestamp on update current_timestamp, check ( ( unit_price * qty ) < 200000 ) );
start transaction; insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 1, 2023, 7, 26, 'kaneko', 'orange A', 1.2, 10 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 2, 2023, 7, 26, 'miyamoto', 'Apple M', 2.5, 2 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 3, 2023, 7, 27, 'kaneko', 'orange B', 1.2, 8 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price) values( 4, 2023, 7, 28, 'miyamoto', 'Apple L', 3 ); commit;
「order_records」をクリックすると,エディタ画面に変わり,テーブルの中身が確認,編集できる.
select * from order_records;
start transaction; update order_records set unit_price = 11.2 where id = 1; commit; select * from order_records;
show tables;
mysqladmin --user=root password "(新しいパスワード)"
すでにパスワードを設定済みで,変更をしたい場合は,次のように操作.
mysqladmin --user=root --password=(古いパスワード) password "(新しいパスワード)"
http://localhost/cgi-bin/perltest.cgi