Phpmyadmin 简明教程

phpMyAdmin - Environment Setup

由于 phpMyAdmin 是基于 PHP 的,因此在安装 phpMyAdmin 之前,您的计算机系统上需要安装以下四个重要组件。

As phpMyAdmin is PHP based, following four vital components need to be installed on your computer system before installing phpMyAdmin.

  1. Web Server − PHP works with virtually all Web Server software, including Microsoft’s Internet Information Server (IIS) but most often used is Apache Server. Download Apache for free here − https://httpd.apache.org/download.cgi. Apache 2.4 is used in this tutorial.

  2. Database − phpMyAdmin manages MySQL or MariaDB databases. In this tutorial, we can using MySQL database. Download MySQL for free here − https://www.mysql.com/downloads/. MySQL 8.0 is used in this tutorial.

  3. PHP Parser − In order to process PHP script instructions, a parser must be installed to generate HTML output that can be sent to the Web Browser. This tutorial will guide you how to install PHP parser on your computer. Php 7.4 is used in this tutorial.

  4. Web Browser − phpMyAdmin is a web based software, so web browser is needed with javascript and cookies enabled. We are using Google Chrome in this tutorial.

PHP Parser Installation

在您进行之前,在计算机上确保设置好适当的环境,以使用 PHP 开发您的网络程序非常重要。将以下 php 文件储存在 Apache 的 htdocs 文件夹中。

Before you proceed, it is important to make sure that you have proper environment setup on your machine to develop your web programs using PHP. Store the following php file in Apache’s htdocs folder.

phpinfo.php

Example

<?php
   phpinfo();
?>

Output

在您的浏览器的地址框中输入以下地址。

Type the following address into your browser’s address box.

http://127.0.0.1/phpinfo.php

如果这样做会显示一个页面,显示您的 PHP 安装相关信息,则表示已正确安装了 PHP 和 Web 服务器。否则,您必须按照给定的程序在计算机上安装 PHP。

If this displays a page showing your PHP installation related information, then it means you have PHP and Webserver installed properly. Otherwise, you have to follow the given procedure to install PHP on your computer.

本部分将指导您在以下四个平台上安装和配置 PHP −

This section will guide you to install and configure PHP over the following four platforms −

Apache Configuration

如果您使用 Apache 作为 Web 服务器,那么本部分将指导您编辑 Apache 配置文件。

If you are using Apache as a Web Server, then this section will guide you to edit Apache Configuration Files.

PHP.INI File Configuration

PHP 配置文件 php.ini 是影响 PHP 功能的最后一种直接方法。

The PHP configuration file, php.ini, is the final and immediate way to affect PHP’s functionality.

在此处查看 − PHP.INI File Configuration

Windows IIS Configuration

要在 Windows 机器上配置 IIS,您可以参考随 IIS 一起提供的 IIS 参考手册。

To configure IIS on your Windows machine, you can refer your IIS Reference Manual shipped along with IIS.

Install MySQL Database

当然,您将需要最重要的实际运行数据库,其中包含您可以查询和修改的表。

The most important thing you will need, of course is an actual running database with a table that you can query and modify.

  1. MySQL DB − MySQL is an open source database. You can download it from MySQL Official Site. We recommend downloading the full Windows installation.

此外,下载并安装 MySQL AdministratorMySQL Query Browser. 。它们是基于 GUI 的工具,可以让您的开发变得更加轻松。

In addition, download and install MySQL Administrator as well as MySQL Query Browser. These are GUI based tools that will make your development much easier.

最后,在方便的目录中下载并解压缩 MySQL Connector/J (MySQL JDBC 驱动程序)。出于本教程的目的,我们假设您已在 C:\Program Files\MySQL\mysql-connector-java-5.1.8 中安装了驱动程序。

Finally, download and unzip MySQL Connector/J (the MySQL JDBC driver) in a convenient directory. For the purpose of this tutorial we will assume that you have installed the driver at C:\Program Files\MySQL\mysql-connector-java-5.1.8.

相应地,将 CLASSPATH 变量设置为 C:\Program Files\MySQL\mysql-connector-java-5.1.8\mysql-connector-java-5.1.8-bin.jar。您的驱动程序版本可能会因您的安装而异。

Accordingly, set CLASSPATH variable to C:\Program Files\MySQL\mysql-connector-java-5.1.8\mysql-connector-java-5.1.8-bin.jar. Your driver version may vary based on your installation.

Set Database Credential

当我们安装 MySQL 数据库时,它的管理员 ID 设置为 root ,并提供设置密码的选项。

When we install MySQL database, its administrator ID is set to root and it gives provision to set a password of your choice.

使用 root ID 和密码,您可以创建另一个用户 ID 和密码,也可以为您的 JDBC 应用程序使用 root ID 和密码。

Using root ID and password you can either create another user ID and password, or you can use root ID and password for your JDBC application.

有各种数据库操作,例如数据库创建和删除,这需要管理员 ID 和密码。

There are various database operations like database creation and deletion, which would need administrator ID and password.

我们将使用 ID root 和密码 root@123 的 MySQL 数据库。

We would use MySQL Database with root as ID and root@123 as password.

如果您没有足够权限创建新用户,那么您可以请求数据库管理员 (DBA) 为您创建用户 ID 和密码。

If you do not have sufficient privilege to create new users, then you can ask your Database Administrator (DBA) to create a user ID and password for you.

要全面了解 MySQL 数据库,请学习 MySQL Tutorial

For a complete understanding on MySQL database, study the MySQL Tutorial.

phpMyAdmin installation

在方便的目录中下载并解压 phpMyAdmin Web 应用程序 phpMyAdmin-5.1.1-all-languages.zip 。然后将该文件夹复制到 Apache Web 服务器的 htdocs 目录中。我们已将 phpMyAdmin-5.1.1-all-languages 重命名为 phpMyAdmin 并将其放在 htdocs 目录中。

Download and unzip phpMyAdmin-5.1.1-all-languages.zip phpMyAdmin web application in a convenient directory. Then copy the folder to htdocs directory of Apache Web Server. We’ve renamed the phpMyAdmin-5.1.1-all-languages to phpMyAdmin and placed it inside the htdocs directory.

在重新启动 Apache 服务器之前,我们需要对 Apache 配置和 PHP 配置进行更改,以允许 phpMyAdmin 与 MySQL 和 OpenSSL 配合工作。请执行以下更改。

Before restarting Apache Server, we need to make changes to Apache Configuration and PHP Configuration to allow phpMyAdmin to work with MySQL and OpenSSL. Please do the following changes.

Apache Configuration Update

在 Apache Web Server 目录中找到 /conf/httpd.conf 文件,并将 DirectoryIndex > index.html 更新为 index.php。

Locate /conf/httpd.conf file in Apache Web Server directory and update DirectoryIndex > index.html to index.php.

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
   DirectoryIndex index.php
</IfModule>

PHP Configuration Updates

在 PHP 安装目录中找到 php.ini ,并取消注释 mysqliopenssl 的扩展。

Locate php.ini in PHP Installation directory and uncomment extensions for mysqli and openssl.

extension=mysqli
extension=openssl

现在启用 extension_dir 以加载 mysqli 和 openssl 的扩展。

Now enable the extension_dir to load extensions for mysqli and openssl.

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"

就是这个,现在启动 Apache 服务器并打开 Web 浏览器中的 localhost/phpmyadmin phpmyadmin 以打开 phpMyAdmin 界面。

That’s it, now start the Apache Server and open localhost/phpmyadmin phpmyadmin in web browser to open the phpMyAdmin interface.