如何安装管理员 MySQL AlmaLinux 上的数据库管理工具

管理员 MySQL (以前的 phpMinAdmin)是最优秀的基于 PHP 的全功能数据库管理工具之一。 您可以使用管理员 MySQL 管理数据库,例如 MySQL, MariaDB、Elasticsearch、MongoDB、PostgreSQL、SQLite、MSSQL、Oracle 等。 它简单、轻便,并且在构建时考虑到了良好的安全性和用户体验。 Adminer 数据库管理器在所有 Linux 分布。 您可以快速管理多个数据库并从管理员 Web 界面进行操作。

您可以使用终端在 AlmaLinux 上快速安装和配置它,您可以使用任何浏览器访问它的 Web 界面。

先决条件

  • 操作系统及版本:AlmaLinux OS 9。
  • 根访问您的 Linux 系统或通过 sudo 命令。

安装管理员 MySQL AlmaLinux 上的数据库管理工具

第 1 步:安装 LAMP 服务器

LAMP 堆栈包括四种不同的软件技术: Linux, Apache, MySQL和PHP。 安装管理员之前 MySQL,您必须安装 Apache 网络服务器, MariaDB 数据库服务器,以及服务器上的 PHP。 您可以执行以下命令来安装它们中的每一个。

~]# dnf install httpd mariadb-server php php-mysqli php-curl php-json -y

这是输出。

[root@noufal-admin ~]# dnf install httpd mariadb-server php php-mysqli php-curl php-json -y
AlmaLinux 9 - AppStream                                                                                                                  3.8 MB/s | 9.6 MB     00:02    
AlmaLinux 9 - BaseOS                                                                                                                     4.7 MB/s | 5.2 MB     00:01    
AlmaLinux 9 - Extras                                                                                                                      17 kB/s |  17 kB     00:01    
Dependencies resolved.
=========================================================================================================================================================================
 Package                                             Architecture                  Version                                        Repository                        Size
=========================================================================================================================================================================
Installing:
 httpd                                               x86_64                        2.4.53-7.el9_1.5                               appstream                         47 k
 mariadb-server                                      x86_64                        3:10.5.16-2.el9_0                              appstream                        9.3 M
 php                                                 x86_64                        8.0.27-1.el9_1                                 appstream                         10 k
 php-common                                          x86_64                        8.0.27-1.el9_1                                 appstream                        667 k
 php-mysqlnd                                         x86_64                        8.0.27-1.el9_1                                 appstream                        151 k

完成所有软件包的安装后,使用以下命令启动并启用 Apache 和 MariaDB 服务。

~]# systemctl start httpd mariadb
~]# systemctl enable httpd mariadb

这是输出。

[root@noufal-admin ~]# systemctl start httpd mariadb
[root@noufal-admin ~]# systemctl enable httpd mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
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.

第 2 步:为管理员创建数据库

对于管理员,您需要创建一个数据库和一个用户。 为此,请使用以下命令登录 MariaDB 迅速的。

~]# mysql

这是输出。

[root@noufal-admin ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 10.5.16-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)]>

一旦登录 MariaDB 提示符下,运行以下命令创建数据库和用户。

MariaDB [(none)]> CREATE DATABASE adminer;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> CREATE USER 'adminer'@'localhost' IDENTIFIED BY 'adminer@password';
Query OK, 0 rows affected (0.001 sec)

您现在可以使用以下命令授予 Adminer 数据库的所有权限。

MariaDB [(none)]> GRANT ALL ON adminer.* TO 'adminer'@'localhost';
Query OK, 0 rows affected (0.001 sec)

使用以下命令,您可以刷新权限并退出 MariaDB 迅速的。

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> EXIT;
Bye

第 3 步:下载管理员

首先,你必须在里面为Adminer创建一个目录 Apache web root 使用下面的命令。

~]# mkdir /var/www/html/adminer

要将目录更改为 Adminer,可以使用以下命令。

~]# cd /var/www/html/adminer

然后,您可以使用以下命令下载 Adminer。

~]# wget -O index.php https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php

这是输出。

[root@noufal-admin adminer]# wget -O index.php https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php
--2023-04-28 08:33:07--  https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/627735/66e88b00-b488-11eb-97d3-a3fefb5f5d21?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230428%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230428T083150Z&X-Amz-Expires=300&X-Amz-Signature=4b53051b26c16aa06224739176c79271910155ccace5cb4e014b0542053779e0&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=627735&response-content-disposition=attachment%3B%20filename%3Dadminer-4.8.1.php&response-content-type=application%2Foctet-stream [following]
--2023-04-28 08:33:07--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/627735/66e88b00-b488-11eb-97d3-a3fefb5f5d21?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230428%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230428T083150Z&X-Amz-Expires=300&X-Amz-Signature=4b53051b26c16aa06224739176c79271910155ccace5cb4e014b0542053779e0&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=627735&response-content-disposition=attachment%3B%20filename%3Dadminer-4.8.1.php&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 476603 (465K) [application/octet-stream]
Saving to: 'index.php'

index.php                                  100%[=====================================================================================>] 465.43K  --.-KB/s    in 0.03s   

2023-04-28 08:33:07 (15.6 MB/s) - 'index.php' saved [476603/476603]

Adminer 目录的所有权和权限必须更改为 Apache 下载完成后的用户。 您可以使用以下命令更改 Adminer 目录的所有权和权限。

~]# chown -R apache:apache /var/www/html/adminer/
~]# chmod -R 775 /var/www/html/adminer/

第 4 步:配置管理员

首先,您必须创建一个 Apache 使用以下命令在 /etc/httpd/conf.d/ 目录下为管理员创建虚拟主机文件。

~]# vi /etc/httpd/conf.d/adminer.conf

然后,添加以下行。 您可以根据您的要求更新这些行。

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/adminer/
     ServerName adminer.testdomain.com
     DirectoryIndex index.php
     ErrorLog /var/log/httpd/adminer-error.log
     CustomLog /var/log/httpd/adminer-access.log combined
</VirtualHost>

添加这些行后,您可以保存并关闭文件。 您必须重新启动 Apache 反映变化的服务。 您可以重新启动 Apache 使用以下命令的服务。

~]# systemctl restart httpd

您可以使用以下命令来验证状态 Apache 服务。

~]# systemctl status httpd

这是输出。

[root@noufal-admin ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: active (running) since Fri 2023-04-28 08:35:47 UTC; 6s ago
       Docs: man:httpd.service(8)
   Main PID: 12740 (httpd)
     Status: "Started, listening on: port 80"
      Tasks: 213 (limit: 12015)
     Memory: 27.4M
        CPU: 74ms
     CGroup: /system.slice/httpd.service
             ├─12740 /usr/sbin/httpd -DFOREGROUND
             ├─12741 /usr/sbin/httpd -DFOREGROUND
             ├─12742 /usr/sbin/httpd -DFOREGROUND
             ├─12743 /usr/sbin/httpd -DFOREGROUND
             └─12744 /usr/sbin/httpd -DFOREGROUND

Apr 28 08:35:47 noufal-admin systemd[1]: Starting The Apache HTTP Server...
Apr 28 08:35:47 noufal-admin httpd[12740]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::cd6:2eff:fe95:ca72%eth0. S>
Apr 28 08:35:47 noufal-admin systemd[1]: Started The Apache HTTP Server.
Apr 28 08:35:47 noufal-admin httpd[12740]: Server configured, listening on: port 80

第 5 步:访问管理员 Web 界面

您可以在 Web 浏览器中使用 URL https://adminer.testdomain.com 访问 Adminer Web 界面。 您将被带到如下所示的页面。

如果您在本地系统上运行 Adminer,则可以通过 https://127.0.0.1/adminer 访问 Adminer Web 界面。 但是,如果Adminer安装在其他服务器上,您可以通过输入其IP地址访问Adminer Web界面,例如https://server-ip-address/adminer。

您现在可以输入您的 MySQL 主机地址、数据库名称、用户名和密码。 然后点击 登录 按钮。

一旦连接到 MySQL,您应该会看到如下所示的页面。

当你点击时,你应该看到下面的页面 服务器 顶部屏幕上的按钮。

如果要创建新数据库,请单击 创建数据库. 然后,输入要创建的数据库名称并按 节省 按钮。

此外,您还可以创建表、视图、过程和函数,以及其他数据库活动。

最后的想法

管理员 MySQL 数据库管理工具是最优秀的 phpMyAdmin 替代品之一。 它不仅占地面积更小,而且工作速度也快得多。 它正在缓慢但稳定地发展。 最新版本的 Adminer 引入了对 PHP 8 环境的支持。 现在您了解了如何安装 Adminer MySQL AlmaLinux 上的数据库管理工具,您现在可以管理您的 MySQL 或者 MariaDB 使用 Adminer 基于 Web 的界面快速创建数据库。