ติดตั้ง MySQL Server และ phpMyAdmin บน Alma Linux
ก่อนติดตั้ง ให้ทำการติดตั้ง Apache HTTPd Server และ PHP ก่อน
– การติดตั้ง Apache
– การติดตั้ง PHP 8
————————
1. ติดตั้ง MySQL Server
dnf install mysql-server mysql -y
2. สั่งสต๊าทการใช้งาน MySQL พร้อมกำหนดให้ทำงานตอนบู๊ตระบบ
[root@agriserv html]# systemctl start mysqld
[root@agriserv html]# systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
3. ตรวจสอบสถานะ
systemctl status mysqld
4. กำหนดรหัสผ่าน MySQL ด้วยคำสั่ง mysql_secure_installation
[root@agriserv html]# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: กดปุ่ม Enter
Please set the password for root here.
New password: รหัสผ่าน
Re-enter new password: ยืนยันรหัสผ่าน
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
‘localhost’. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named ‘test’ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
– Dropping test database…
Success.
– Removing privileges on test database…
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
——————-
5. ทดสอบเข้าใช้งานทาง Terminal ด้วยคำสั่ง mysql -u root -p
[root@agriserv html]# mysql -u root -p
passwd: กำหนดรหัสผ่าน
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.30 Source distribution
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| sys |
+——————–+
4 rows in set (0.00 sec)
mysql> exit
——————————–
6. ติดตั้ง phpMyAdmin จากแหล่งเก็บ EPEL
[root@agriserv html]# dnf install phpmyadmin -y
[root@agriserv html]# dnf install phpMyAdmin -y
Last metadata expiration check: 1:10:55 ago on Sun Mar 12 12:18:58 2023.
No match for argument: phpMyAdmin
Error: Unable to find a match: phpMyAdmin
[root@agriserv html]# dnf install epel-release -y
Last metadata expiration check: 1:11:05 ago on Sun Mar 12 12:18:58 2023.
Dependencies resolved.
==============================================================================================
Package Architecture Version Repository Size
==============================================================================================
Installing:
epel-release noarch 9-2.el9 extras 17 k
Transaction Summary
==============================================================================================
Install 1 Package
Total download size: 17 k
Installed size: 23 k
Downloading Packages:
epel-release-9-2.el9.noarch.rpm 24 kB/s | 17 kB 00:00
———————————————————————————————-
Total 8.2 kB/s | 17 kB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : epel-release-9-2.el9.noarch 1/1
Running scriptlet: epel-release-9-2.el9.noarch 1/1
Verifying : epel-release-9-2.el9.noarch 1/1
Installed:
epel-release-9-2.el9.noarch
Complete!
—————————-
7. ปรับแต่งคอนฟิก phpMyadmin โดยเพิ่มบรรทัด Require all granted ลงไป
[root@agriserv html]# vi /etc/httpd/conf.d/phpMyAdmin.conf
# phpMyAdmin – Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
Require all granted
Require local
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
Require local
</Directory>
————————
8. ทำการรีสต๊าท Apache
[root@agriserv html]# systemctl restart httpd
9. ทดสอบเรียกใช้งาน phpMyAdmin ทางเว็บเบราเซอร์
http://IP_Address/phpMyAdmin
หรือ
http://IP_Address/phpทyadmin
เช่น
http://localhost/phpmyadmin/
10. ทำการป้อนชื่อเรียกเพื่อเขาระบบ
Username: root
Password: รหัสผ่านที่กำหนดในข้อ 4
แสดงโปรแกรม phpMyAdmin
—
Write by SysAdmin Knowledge
https://www.sysadmin.in.th
January 22, 2023