SlideShare a Scribd company logo
1 of 13
Download to read offline
MariaDBサーバーソフトウェア mariadb-server のインストール
dnf list vsftpd
「利用可能なパッケージ」として表示されることを確認します。
dnf install vsftpd
MariaDBをインストールするために必要な依存パッケージも同時にインストールされます 。
「完了しました!」と表示されたらインストール完了です。
DBサーバーのインストール1
利用可能なパッケージ
mariadb-server.x86_64 3:10.3.17-1.module_el8.1.0+257+48736ea6 AppStream
perl-Unicode-Normalize-1.25-396.el8.x86_64 perl-constant-1.33-396.el8.noarch
perl-interpreter-4:5.26.3-416.el8.x86_64 perl-libnet-3.11-3.el8.noarch
perl-libs-4:5.26.3-416.el8.x86_64 perl-macros-4:5.26.3-416.el8.x86_64
perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch
perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64
psmisc-23.1-4.el8.x86_64
完了しました!
手順1 [root@suzukto ~]# dnf␣list␣mariadb-server
手順2 [root@suzukto ~]# dnf␣install␣mariadb-server
[root@localhost ~]# dnf install mariadb-server
pid 1743 のプロセスが終了するのを待ちます。
^CKeyboardInterrupt: 終了しました。
[root@localhost ~]# kill 1743
関連ソフトウェアのインストール
MariaDB用PHPソフトウェア php-mysqlnd のインストール
dnf list
「利用可能なパッケージ」として表示されることを確認します。
dnf install
「完了しました!」と表示されたらインストール完了です。
2
利用可能なパッケージ
php-mysqlnd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream
php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
完了しました!
手順3 [root@suzukto ~]# dnf␣list␣php-mysqlnd
手順4 [root@suzukto ~]# dnf␣install␣php-mysqlnd
DBサーバーの初期設定(1)
MariaDBのインストール確認
--version
MariaDBの起動
systemctl start
MariaDBの起動確認
Systemctl status
自動起動設定もあわせて設定します。
Systemctl enable
3
手順6 [root@suzukto ~]# systemctl␣start␣mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-30 05:50:28 JST; 2s ago
Docs: man:mysqld(8)
手順5 [root@suzukto ~]# mysql␣--version
mysql Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1
手順8 [root@suzukto ~]# systemctl␣enable␣mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service →
/usr/lib/systemd/system/mariadb.service.
手順7 [root@suzukto ~]# systemctl␣status␣mariadb
DBサーバーの初期設定(2)
MariaDBの自動起動確認
--version
4
手順9 [root@suzukto ~]# systemctl␣status␣mariadb
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-12-30 05:50:28 JST; 15min ago
Docs: man:mysqld(8)
DBサーバーの初期設定(3)
MariaDBの初期化
環境によって設定の差異が出ないように初期化します。
mysql_secure_installation
Enter current password for root (enter for none):
Enterを押します。rootの初期パスワードは空です。
Set root password? [Y/n]
「y」で応答し、rootユーザーのパスワードを設定します。
Remove anonymous users? [Y/n]
「y」で応答し、匿名ユーザーを削除します。
5
手順10 [root@suzukto ~]#mysql_secure_installation
Set root password? [Y/n] Y
New password: ←P@ssw0rdを入力します。(表示はされません)
Re-enter new password: ←確認のためもう一度入力します。
Password updated successfully! ←成功しました。
Reloading privilege tables..
... Success!
... Success!
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Enter current password for root (enter for none):
DBサーバーの初期設定(4)
Disallow root login remotely? [Y/n]
「y」で応答し、rootユーザーのリモートログインを無効化します。
Remove test database and access to it? [Y/n]
「y」で応答し、デフォルトで作成されているテストデータベースを削除します。
Reload privilege tables now? [Y/n]
「y」で応答し、権限テーブルを再読み込みします
「Cleaning up...」と表示されたら初期化成功です。
6
Disallow root login remotely? [Y/n] Y
... Success!
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
... Success!
DBサーバーへの接続とDB/ユーザー作成(1)
MariaDBへ接続
mysql mysql #mysql –u root –p
プロンプトが変化していればログイン成功です。
7
手順11[root@suzukto ~]#mysql□-u␣root␣-p
Enter password: ←パスワードを入力します。
Welcome to the MariaDB monitor. Commands end with ; or ¥g.
Your MariaDB connection id is 21
Server version: 10.3.17-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '¥h' for help. Type '¥c' to clear the current input statement.
MariaDB [(none)]>
DBサーバーへの接続とDB/ユーザー作成(2)
データベース作成
データ入力などで使用するためのデータベースを作成します
create database webdb default character set = utf8;
データベースが追加されているか確認します
show database;
8
手順12 MariaDB [(none)]> create␣database␣webdb␣default␣character␣set␣=␣utf8;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> create database webdb default character set = utf8
->
(セミコロン忘れ)
手順13 MariaDB [(none)]> show␣databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| webdb |
+--------------------+
4 rows in set (0.001 sec)
DBサーバーへの接続とDB/ユーザー作成(3)
ユーザーの作成
データ入力などで使用するためのユーザー/パスワードを作成します
create user webuser@’%’ identified by ‘{パスワード}’
先ほど作成したデータベースに対して全ての権限を与えます
grant all on webdb.* to webuser@’%’;
権限が付与されているか確認します
show grants for webuser@’%’;
9
手順14 MariaDB [(none)]> create␣user␣webuser@’%'␣identified␣by␣'P@ssw0rd';
Query OK, 1 row affected (0.001 sec)
手順15 MariaDB [(none)]> grant␣all␣on␣webdb.*␣to␣webuser@’%';
Query OK, 1 row affected (0.001 sec)
手順16 MariaDB [(none)]> show␣grants␣for␣webuser@’%';
+--------------------------------------------------------------------------------------------------------+
| Grants for webuser@% |
+--------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'webuser'@'%' IDENTIFIED BY PASSWORD '*8232A1298A49F710DBEE0B330C42EEC825D4190A' |
| GRANT ALL PRIVILEGES ON `webdb`.* TO 'webuser'@'%' |
+--------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)
もし権限がなかったら
flush privileges;
DBへのデータ入力、検索(1)
WebuserでMariaDBへ接続
MariaDBから抜けます
exit
使用するDBを選択してMariaDBへ接続
mysql –uwebuser –p webdb
データを格納するためのテーブルを作成
create table test_table (
10
手順17 MariaDB [(none)]> exit
Bye
手順18 [root@suzukto ~]# mysql␣–u␣webuser␣–p␣webdb
手順19
MariaDB [webdb]> create table test_table (
-> col1 int primary key,
-> col2 varchar(32) not null
-> );
Query OK, 0 rows affected (0.011 sec)
Enter password: ←パスワードを入力します。
DBへのデータ入力、検索(2)
テーブルにデータ入力
insert into test_table (col1, col2) values (1, ‘test row 1’);
データ内容は各自自由に設定してください。
入力したデータを検索します。
select * from test_table;
11
手順20
MariaDB [webdb]> insert␣into␣test_table␣values (1, ‘Pikachu’);
MariaDB [webdb]> insert␣into␣test_table␣values (2, ‘yamada’);
手順21 MariaDB [webdb]> select␣*␣from␣test_table;
+------+---------+
| col1 | col2 |
+------+---------+
| 1 | Pikachu |
| 2 | yamada |
+------+---------+
2 rows in set (0.000 sec)
Query OK, 1 row affected (0.002 sec)
MariaDB [(none)]> exit
PHPとMariaDBの連携(1)
PHPから相方サーバーのMariaDBへ接続し、データを取得してみます。
次の内容のファイルを/var/www/html/selectdb.phpとして作成してください。
Vi /var/www/html/selectdb.php
作成したPHPファイルをWebブラウザから確認します。
http://192.168.210.XXX/selectdb.php
12
<?php
$db=mysqli_connect('localhost','webuser','P@ssw0rd','webdb');
$res=mysqli_query($db,'select * from test_table');
while($row=mysqli_fetch_array($res)){
printf("%s %s<br/>¥n",$row[0],$row[1]);
}
?>
手順22 [root@suzukto ~]# vi␣/var/www/html/selectdb.php
手順23
↑第4オクテッドは自分のサーバで
PHPとMariaDBの連携(2)
作成したPHPファイルをWebブラウザから確認します。
おしまい
13

More Related Content

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (20)

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn
 

Featured (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Linux#4