当前位置: 首页 > 编程文章 >

phpMyAdmin 配置文件 config.default.php 详解与安装指南

phpMyAdmin 配置文件 config.default.php 详解与安装指南

作者:叶安时间:2026-09-17 11:04:49浏览:978

phpMyAdmin 是一款通过 Web 界面直接管理 MySQL 数据库的工具,适合不熟悉命令行操作的数据库管理者。本文详细解析了 config.default.php 中的核心配置项,包括访问网址、主机信息、认证方法(cookie/http/config)及短语密码设置,并提供了从下载到部署的完整步骤及 mysqli 扩展缺失等常见错误的解决方法。

本文目录收起

phpMyAdmin 简介与安装准备

对于不熟悉数据库操作命令的管理者而言,使用图形化工具是理想选择。以下将介绍该工具的具体安装流程。


首先从网络下载 phpmyadmin 压缩包,将其解压至可被 Web 服务器访问的目录中。若使用虚拟空间,需通过 FTP 上传解压后的文件。此外,用户可根据需要修改解压后文件夹的名称。


完成文件部署后,需进行配置文件 config 的设置。


打开 libraries 目录下的 config.default.php 文件,依据后续说明逐项调整配置参数。


A. 访问网址配置


参考代码:


$cfg['PmaAbsoluteUri'] = ''; 此处需填入 phpmyadmin 的实际访问 URL。


B. MySQL 主机信息配置


参考代码:


$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address


填写 localhost 或 MySQL 服务器的 IP 地址。若 phpmyadmin 与 MySQL 位于同一服务器,通常保持默认 localhost 即可。


$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port


指定 MySQL 端口,若使用默认端口 3306,此项留空即可。


C. MySQL 用户名和密码配置


参考代码:


$cfg['Servers'][$i]['user'] = 'root'; // MySQL user 访问phpmyadmin使用的mysql用户名


$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed对应上述mysql用户名的密码


D. 认证方法配置


参考代码:


$cfg['Servers'][$i]['auth_type'] = 'cookie';


此处提供四种认证模式:cookie、http、HTTP 和 config。


config 模式允许直接通过访问网址进入,无需输入用户名和密码,因存在安全隐患,不建议使用。


当设置为 cookie、http 或 HTTP 时,登录 phpmyadmin 必须进行用户名和密码验证,具体适用场景如下:


若 PHP 以 Apache 模块方式安装,支持 http 和 cookie 模式;


若 PHP 以 CGI 方式安装,仅支持 cookie 模式。


E. 短语密码 (blowfish_secret) 设置


参考代码:


$cfg['blowfish_secret'] = '';


若认证方法设为 cookie,必须在此处设置短语密码。密码内容由用户自定义,但绝不能留空,否则登录时将报错。


至此,phpmyadmin 的基本安装配置已完成,用户可以登录体验。


说明:


上述内容仅涵盖基本安装配置。关于 config.default.php 中各参数的详细说明,请参阅官方文档。


phpMyAdmin 是一种基于 Web 的 MySQL 数据库管理工具,安装后可通过浏览器直接管理数据库,无需执行系统命令,非常适合对数据库操作命令不熟悉的数据库管理者,下面详细说明该工具的安装方法。


一、下载


1、前往官方站点下载 phpMyAdmin 安装包:http://www.phpmyadmin.net/ (建议选择包含所有语言的 all-languages 版本)。


2、将文件解压到 Web 可访问的目录下。若是虚拟空间,可通过 FTP 工具上传。同时,您可以自定义解压后的目录名称。


二、配置


3、打开 /libraries/config.default.php 文件(旧版本为根目录下的 config.inc.php),使用写字板(注意:勿用记事本,因文件为 UTF-8 编码)进行编辑并按说明配置。


4、查找 $cfg['PmaAbsoluteUri']=‘'; // 修改为你将上传到空间的phpMyAdmin的网址


例如:$cfg['PmaAbsoluteUri'] =‘http: // 网站域名/phpmyadmin/';


5、查找 $cfg['Servers'][$i]['host'] =‘localhost'; // 通常用默认,也有例外,可以不用修改


6、查找 $cfg['Servers'][$i]['auth_type'] =‘config'; // 在自己的机子里调试用config;如果在网络上的空间用cookie.


在此有四种模式可供选择:cookie,http,HTTP,config


① config 方式即输入phpMyAdmin 的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。


② 设置cookie,http,HTTP方式,登录 phpMyAdmin 需要数据用户名和密码进行验证。


具体如下:PHP 安装模式为 Apache,可以使用 http 和 cookie;PHP 安装模式为 CGI,可以使用 cookie。


7、查找 $cfg['Servers'][$i]['user'] = ‘root'; // MySQL用户名


8、查找 $cfg['Servers'][$i]['password'] =''; // MySQL 密码 (only needed 留空就可以了)


9、查找 $cfg['Servers'][$i]['only_db'] = ''; // 你只有一个数据就设置一下,设置为你的数据库名;如果你想架设服务器,那么建议留空


10、查找 $cfg['DefaultLang'] = ‘zh'; // 这里是选择语言,zh代表简体中文的意思


11、查找$cfg['blowfish_secret'] =''; // 如果认证方法设置为cookie,就需要设置短语密码,设置为什么密码,由您自己决定,这里不能留空,否则会在登录 phpMyAdmin 时提示如下图所示的错误。


12、设置完毕后保存,现在可以上传到网络空间上了,浏览http://网站域名/phpmyadmin/测试一下。(输入数据库的用户名及密码就可以了) 如果要安装过程中出现:“phpMyAdmin - 错误 缺少 mysqli 扩展。请检查 PHP 配置。”错误。 解决方法如下: ①到phpmyadmin文件夹的\libraries\config.default.php文件中找:$cfg['Servers'][$i]['extension']='mysql';语句。 ②如果有找到$cfg['Servers'][$i]['extension']='mysql';这句,就继续查找下面这句$cfg['Servers'][$i]['extension']='mysqli'; 并把其的注释去掉。 ③如果没有找到$cfg['Servers'][$i]['extension']='mysql';这句,就把$cfg['Servers'][$i]['extension']='mysqli';语句,改成$cfg['Servers'][$i]['extension']='mysql'; 语句。(即确保 " mysql " 值能生效)


<?php
/* $Id: config.inc.php,v 1.204.2.1 2003/10/10 14:24:24 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:

/** * phpMyAdmin Configuration File * * All directives are explained in Documentation.html */

/** * Sets the php error reporting - Please do not change this line! */ if (!isset($old_error_reporting)) { error_reporting(E_ALL); @ini_set('display_errors', '1'); }

/** * Your phpMyAdmin url * * Complete the variable below with the full url ie * http://www.your_web.net/path_to_your_phpMyAdmin_directory/ * * It must contain characters that are valid for a URL, and the path is * case sensitive on some Web servers, for example Unix-based servers. * * In most cases you can leave this variable empty, as the correct value * will be detected automatically. However, we recommend that you do * test to see that the auto-detection code works in your system. A good * test is to browse a table, then edit a row and save it. There will be * an error message if phpMyAdmin cannot auto-detect the correct value. * * If the auto-detection code does work properly, you can set to TRUE the * $cfg['PmaAbsoluteUri_DisableWarning'] variable below. */ $cfg['PmaAbsoluteUri'] = '';-----这里设置你的phpmyadmin的URL,如:http://localhost/phpmyadmin/

/** * Disable the default warning about $cfg['PmaAbsoluteUri'] not being set * You should use this if and ONLY if the PmaAbsoluteUri auto-detection * works perfectly. */ $cfg['PmaAbsoluteUri_DisableWarning'] = FALSE;

/** * Disable the default warning that is displayed on the DB Details Structure page if * any of the required Tables for the relationfeatures could not be found */ $cfg['PmaNoRelation_DisableWarning'] = FALSE;

/** * The 'cookie' auth_type uses blowfish algorithm to encrypt the password. If * at least one server configuration uses 'cookie' auth_type, enter here a * passphrase that will be used by blowfish. $cfg['blowfish_secret'] = '';-----设定好root密码后这里也要填写

/** * Server(s) configuration */ $i = 0; // The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use $cfg['Servers'][0]. // You can disable a server config entry by setting host to ''. $i++; $cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address----这里可以设定远程MySQL服务器IP地址

$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port-----默认为3306

$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket

$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')-----连接MySQL服务器的方式

$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection // (requires PHP >= 4.3.0)-----是否使用压缩协议,PHP版本须>= 4.3.0

$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings // (this user must have read-only $cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user" // and "mysql/db" tables)-----MySQL控制用户设定,该用户只对mysql数据库下的user和db表有完全权限

$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?-----如果PHP安装模式为Apache,可以使用http和cookie;如果PHP安装模式为CGI,可以使用cookie;默认为config,是不安全的,不推荐。

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user-----MySQL连接用户

$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed with 'config' auth_type)-----MySQL连接密码,建议在安装好PHP和MySQL后,先用phpmyadmin设定root密码,然后在这里填写

$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only // this db is displayed // at left frame // It may also be an array // of db-names-----如果在这里设定一个数据库的名字,那么登陆后框架左边将只显示这个数据库

$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname

$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features // (see scripts/create_tables.sql) // - leave blank for no support // DEFAULT: 'phpmyadmin' $cfg['Servers'][$i]['bookmarktable'] = ''; // Bookmark table // - leave blank for no bookmark support // DEFAULT: 'pma_bookmark' $cfg['Servers'][$i]['relation'] = ''; // table to describe the relation between links (see doc) // - leave blank for no relation-links support // DEFAULT: 'pma_relation' $cfg['Servers'][$i]['table_info'] = ''; // table to describe the display fields // - leave blank for no display fields support // DEFAULT: 'pma_table_info' $cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF schema // - leave blank for no PDF schema support // DEFAULT: 'pma_table_coords' $cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf // - leave blank if you don't want to use this // DEFAULT: 'pma_pdf_pages' $cfg['Servers'][$i]['column_info'] = ''; // table to store column information // - leave blank for no column comments/mime types // DEFAULT: 'pma_column_info' $cfg['Servers'][$i]['history'] = ''; // table to store SQL history // - leave blank for no SQL query history // DEFAULT: 'pma_history' $cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your pma_* tables // are up to date. This prevents compatibility // checks and thereby increases performance. $cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults = array();

$i++; $cfg['Servers'][$i]['host'] = ''; $cfg['Servers'][$i]['port'] = ''; $cfg['Servers'][$i]['socket'] = ''; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = FALSE; $cfg['Servers'][$i]['controluser'] = ''; $cfg['Servers'][$i]['controlpass'] = ''; $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = ''; $cfg['Servers'][$i]['only_db'] = ''; $cfg['Servers'][$i]['verbose'] = ''; $cfg['Servers'][$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql $cfg['Servers'][$i]['bookmarktable'] = ''; // 'pma_bookmark' $cfg['Servers'][$i]['relation'] = ''; // 'pma_relation' $cfg['Servers'][$i]['table_info'] = ''; // 'pma_table_info' $cfg['Servers'][$i]['table_coords'] = ''; // 'pma_table_coords' $cfg['Servers'][$i]['pdf_pages'] = ''; // 'pma_pdf_pages' $cfg['Servers'][$i]['column_info'] = ''; // 'pma_column_info' $cfg['Servers'][$i]['history'] = ''; // 'pma_history' $cfg['Servers'][$i]['verbose_check'] = TRUE; $cfg['Servers'][$i]['AllowDeny']['order'] = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] = array();

$i++; $cfg['Servers'][$i]['host'] = ''; $cfg['Servers'][$i]['port'] = ''; $cfg['Servers'][$i]['socket'] = ''; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = FALSE; $cfg['Servers'][$i]['controluser'] = ''; $cfg['Servers'][$i]['controlpass'] = ''; $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = ''; $cfg['Servers'][$i]['only_db'] = ''; $cfg['Servers'][$i]['verbose'] = ''; $cfg['Servers'][$i]['pmadb'] = ''; // 'phpmyadmin' - see scripts/create_tables.sql $cfg['Servers'][$i]['bookmarktable'] = ''; // 'pma_bookmark' $cfg['Servers'][$i]['relation'] = ''; // 'pma_relation' $cfg['Servers'][$i]['table_info'] = ''; // 'pma_table_info' $cfg['Servers'][$i]['table_coords'] = ''; // 'pma_table_coords' $cfg['Servers'][$i]['pdf_pages'] = ''; // 'pma_pdf_pages' $cfg['Servers'][$i]['column_info'] = ''; // 'pma_column_info' $cfg['Servers'][$i]['history'] = ''; // 'pma_history' $cfg['Servers'][$i]['verbose_check'] = TRUE; $cfg['Servers'][$i]['AllowDeny']['order'] = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] = array();

// If you have more than one server configured, you can set $cfg['ServerDefault'] // to any one of them to autoconnect to that server when phpMyAdmin is started, // or set it to 0 to be given a list of servers without logging in // If you have only one server configured, $cfg['ServerDefault'] *MUST* be // set to that server.[color]=red]-----是否显示所有的MySQL服务器 $cfg['ServerDefault'] = 1; // Default server (0 = no default server) $cfg['Server'] = ''; unset($cfg['Servers'][0]);

/** * Other core phpMyAdmin settings */ $cfg['OBGzip'] = 'auto'; // use GZIP output buffering if possible (TRUE|FALSE|'auto')-----有必要的话是否使用GZIP输出缓冲

$cfg['PersistentConnections'] = FALSE; // use persistent connections to MySQL database-----是否使用MySQL持久连接,即pconnect

$cfg['ExecTimeLimit'] = 300; // maximum execution time in seconds (0 for no limit)-----最大脚本执行时间,单位:秒

$cfg['SkipLockedTables'] = FALSE; // mark used tables, make possible to show // locked tables (since MySQL 3.23.30) $cfg['ShowSQL'] = TRUE; // show SQL queries as run-----运行查询时显示SQL查询语句

$cfg['AllowUserDropDatabase'] = FALSE; // show a 'Drop database' link to normal users-----是否对普通用户显示“删除数据库”连接

$cfg['Confirm'] = TRUE; // confirm 'DROP TABLE' & 'DROP DATABASE'-----删除数据表/库前是否出现确认提示框

$cfg['LoginCookieRecall'] = TRUE; // recall previous login in cookie auth. mode or not-----是否收回先前cookie认证模式的cookie

$cfg['UseDbSearch'] = TRUE; // whether to enable the "database search" feature // or not $cfg['IgnoreMultiSubmitErrors'] = FALSE; // if set to true, PMA continues computing multiple-statement queries // even if one of the queries failed $cfg['VerboseMultiSubmit'] = TRUE; // if set to true, PMA will show the affected rows of EACH statement on // multiple-statement queries. See the read_dump.php file for hardcoded // defaults on how many queries a statement may contain! $cfg['AllowArbitraryServer'] = FALSE; // allow login to any user entered server in cookie based auth

上一篇
PHP 临时文件操作指南:获取目录与创建方法

本文介绍 PHP 中临时文件的获取与创建方法。通过 sys_get_temp_dir 获取默认临时目录,使用 tmpfile 创建自动删除的可读写文件,以及利用 tempnam 根据目录权限生成带前缀的唯一名称临时文件,帮助开发者高效处理缓存与临时数据。

下一篇
PHP端口嗅探器:指定网站与端口的HTTP请求检测

该PHP脚本通过fsockopen函数建立与服务器的网络连接,发送HEAD HTTP/1.0请求以探测指定网站和端口的连通性。程序接收用户输入的服务器地址和端口号,执行查询后返回连接状态及响应数据,适用于快速验证特定服务是否在线。

相关文章

更多
MySQL字段修饰符详解:NULL、DEFAULT与AUTO_INCREMENT

本文介绍MySQL中常用的字段修饰符,包括NULL、NOT NULL、DEFAULT以及AUTO_INCREMENT。通过具体示例说明如何设置字段非空限制、默认值处理机制以及自增主键的生成规则,帮助开发者正确理解并应用这些约束条件。

2025.02.13 906
phpMyAdmin MySQL 加密配置方法

本文以 phpMyAdmin-2.6.1.tar.gz 为例,详细说明如何通过修改 config.inc.php 文件实现 MySQL 的 HTTP 加密认证。主要步骤包括将 auth_type 改为 http,设置数据库用户名和密码,以及配置 PmaAbsoluteUri 绝对路径,确保访问安全与正确路由。

2025.11.29 837
phpMyAdmin 3.1.3.1 安装配置与常见问题解决

本文介绍 phpMyAdmin 3.1.3.1 在 Windows 本地环境下的安装配置流程,涵盖从下载解压到修改 config.inc.php 关键参数的详细步骤。针对新手常遇到的“无法载入mcrypt扩展”、“配置文件需要绝密短语密码”以及“#2003-服务器没有响应”等典型错误,提供了包括 DLL 文件复制、PHP.ini 设置及 MySQL 服务状态检查在内的具体解决方案。

2026.10.15 831
使用phpMyAdmin创建MySQL数据库及独立用户权限配置指南

本文介绍在phpMyAdmin界面中创建新数据库并分配独立用户权限的操作流程。首先通过选择utf8_general_ci编码建立数据库,随后添加仅限localhost登录的新用户,并在按数据库指定权限中勾选除最后三项外的结构权限,实现单一用户对特定库的完全管理。同时提供隐藏INFORMATION_SCHEMA显示及自动创建前缀数据库的配置方法。

2025.01.23 828
解决phpMyAdmin #2003服务器无响应错误的方法

在使用phpMyAdmin时遇到#2003“服务器没有响应”错误,通常由MySQL服务未启动、认证配置错误或端口被防火墙拦截引起。本文总结了针对APMServ环境的mysqld-nt.exe手动启动方法,以及通过修改config.default.php中的auth_type为http或补全root密码的解决方案,同时提供了重置MySQL密码及检查防火墙端口的辅助手段。

2026.10.27 815
Linux下基于php-fpm模式搭建LAMP及phpMyAdmin详解

本文介绍在Linux系统中基于php-fpm模式搭建LAMP(Linux、Apache、MySQL/MariaDB、PHP)平台并部署phpMyAdmin管理工具的完整流程。主要步骤包括安装httpd、php-fpm及mariadb-server等服务,配置MariaDB数据库与防火墙策略,调整php-fpm会话目录权限,并通过编辑Apache虚拟主机配置文件实现域名绑定。最终通过解压phpMyAdmin源码包、复制配置文件并授予远程访问权限,完成Web端数据库管理界面的部署与访问。

2026.05.18 792

专题推荐

更多
PHP 类与对象定义及继承

先看类声明、对象实例与属性访问。理解对象的创建和销毁后,再读继承、方法重载和关键字对照。已有代码遇到继承行为差异时,可进一步查看 final 方法与反射实例。

PHP 定时任务配置与运行

先确定任务运行间隔以及是否允许重叠。固定时间触发先看 Cron 案例,框架内和常驻服务再读对应示例。

Yii2 队列配置与常驻运行

先用一个最小任务跑通入队和消费,再检查 Web 与 Console 是否加载了相同的队列配置。确认命令能手动运行后再配置 Supervisor,最后验证进程重启时的处理情况。

PHP Session 过期时间设置方法

浏览器关闭、服务端回收和业务规定的闲置超时,可能在不同时间发生。对照配置项与应用层时间戳的做法,检查会话何时仍可读、何时应要求重新登录。

PHP URL 编码和解码方法

URL 路径片段和查询参数对空格的处理方式不同。先比较 urlencode 与 rawurlencode,再沿解码过程核对中文、加号和百分号,检查地址是否被重复编码或提前解码。

在线工具箱

更多
键码查询
键码查询

按下键盘按键时查看浏览器记录的键名和事件信息。

.env 配置检查
.env 配置检查

本地检查 .env 键值语法、引号、重复键及空值,预览解析结果,辅助排查 PHP 和 Laravel 环境配置。

进制转换
进制转换

转换二进制、十进制、十六进制等数值表示,辅助程序调试与进制学习。

HTML 标签安全清理
HTML 标签安全清理

清理 HTML 片段中的标签或危险内容,辅助整理待展示的文本。

文件 Base64 转换
文件 Base64 转换

把文件转为 Base64 文本,也可将编码内容还原为文件,方便接口传输与调试。