How to Install MySQL and phpMyAdmin on AlmaLinux 8.4

mysql vps

How to Install MySQL and phpMyAdmin on AlmaLinux 8.4

How to Install MySQL and phpMyAdmin on AlmaLinux 8.4

This guide will walk you through the secure installation of MySQL and phpMyAdmin on AlmaLinux 8.4, ensuring all configurations are properly set up for a secure environment.

You can automate the installation by using the following Bash script:

Prerequisites

  • A fresh installation of AlmaLinux 8.4.
  • Root or sudo privileges.

Step 1: Import the AlmaLinux GPG Key

Start by importing the AlmaLinux GPG key to ensure package authenticity.

rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

Import the AlmaLinux GPG Key

Step 2: Update the System

It’s crucial to keep your system updated to avoid vulnerabilities. Update all packages using:

yum update -y

Update the System

Step 3: Install MySQL

First, add the MySQL repository:

sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm -y

Install MySQL

Then, install the MySQL server package.

sudo dnf install mysql-server -y

install the MySQL server package

Step 4: Start and Enable MySQL Service

Start the MySQL service and enable it to run at startup.

sudo systemctl start mysqld

Start and Enable MySQL Service
sudo systemctl enable mysqld
Start and Enable MySQL Service 2

Step 5: Secure MySQL Installation

Run the MySQL secure installation script to enhance the security of your MySQL serve:

You can set your password based on length Type 0 for Low and and 1 for medium 2 for Strong and then write your password, confirm and press Enter.

Secure MySQL Installation

Secure MySQL Installation2
Now we must to remove anonymous users as below:
Secure MySQL Installation 3
Next question is for disallow root login remotely as below:
Secure MySQL Installation 4
Remove test database and access as below:
Secure MySQL Installation5
The last action in secure MySQL Installation is to reload privilege tables.
Secure MySQL Installation 6

Step 6: Login to MySQL

Log in to MySQL using the root account.

mysql -u root -p

 

Login to MySQL

After entering the root password, you will access the MySQL shell.  switch to root user again to complete our process

Step 7: Install EPEL Repository

The EPEL (Extra Packages for Enterprise Linux) repository is required for additional packages.

sudo dnf install epel-release -y

Install EPEL Repository

Step 8: Install Remi Repository

Install the Remi repository to get the latest PHP versions.

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Install Remi Repository

sudo dnf config-manager –set-enabled remi

Install Remi Repository 2

Step 9: Install phpMyAdmin

Now, install phpMyAdmin, a web-based interface for MySQL

sudo dnf install -y phpMyAdmin

Install phpMyAdmin0

Step 10: Configure phpMyAdmin

Edit the phpMyAdmin configuration file to allow access.

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Configure phpMyAdmin

Step 11: Restart Apache Service

Restart the Apache web server to apply the changes.

sudo systemctl restart httpd

Step 12: Configure Firewall

Ensure that the firewall allows HTTP and HTTPS traffic.

sudo yum install firewalld -y

Configure Firewall

sudo systemctl enable firewalld

Configure Firewall2

sudo systemctl start firewalld

Configure Firewall3

sudo firewall-cmd –permanent –add-service=http

Configure Firewall4

sudo firewall-cmd –permanent –add-service=https

Configure Firewall5

sudo firewall-cmd –reload

Configure Firewall6

Step 13: Change Apache Port (Optional)

If you need Apache to listen on a different port, update the Listen directive in the configuration file.

sudo nano /etc/httpd/conf/httpd.conf

Update the Listen directive to:

Listen 8080

Change Apache Port (Optional)1

Then, configure the firewall to allow traffic on the new port.

Change Apache Port (Optional)2

sudo firewall-cmd –reload

Change Apache Port (Optional)3

Finally, restart the Apache service.

sudo systemctl restart httpd

Change Apache Port (Optional)4

Accessing phpMyAdmin

After completing these steps, you can access phpMyAdmin by navigating to:

Accessing phpMyAdmin1

Accessing phpMyAdmin2

 

Conclusion

By following these steps, you have securely installed MySQL and phpMyAdmin on AlmaLinux 8.4. Regularly update your system and monitor your services to maintain a secure environment.

Post Your Comment

Free Migration Assistance

If you need assistance with migrating your current data from another provider, we would be more than happy to assist.

Limited Special Promo Code - Free Setup on all VPS plans when using code
This is default text for notification bar