phpMyAdmin 配置
1. 找到并编辑配置文件
phpMyAdmin 5.0.0 的配置文件是 config.inc.php,位于安装目录:
bash
运行
cd /www/server/phpmyadmin/ # 根据实际安装路径调整
如果没有此文件,复制示例文件:
bash
运行
cp config.sample.inc.php config.inc.php
2. 配置远程连接参数
编辑 config.inc.php,找到以下部分并修改:
php
运行
$i = 0;
// 第一个服务器配置
$i++;
$cfg['Servers'][$i]['host'] = 'localhost'; // 修改为远程服务器IP或域名
$cfg['Servers'][$i]['port'] = '3306'; // 保持默认,除非远程MySQL使用其他端口
$cfg['Servers'][$i]['user'] = 'root'; // 修改为之前创建的远程用户
$cfg['Servers'][$i]['password'] = ''; // 修改为远程用户密码
$cfg['Servers'][$i]['auth_type'] = 'config'; // 配置验证方式
添加多个服务器(可选):
php
运行
// 第二个服务器配置
$i++;
$cfg['Servers'][$i]['host'] = '192.168.1.2';
$cfg['Servers'][$i]['user'] = 'user2';
$cfg['Servers'][$i]['password'] = 'pass2';
如果希望在登录页面选择服务器,添加:
php
运行
$cfg['AllowArbitraryServer'] = true; // 允许用户输入任意服务器地址
保存文件并重启 Web 服务器(Apache/Nginx):
bash
运行
# Apache
sudo systemctl restart apache2
# Nginx
sudo systemctl restart nginx
三、通过浏览器访问远程数据库
打开浏览器,访问 phpMyAdmin:
plaintext
http://your_phpmyadmin_server_ip/phpmyadmin
phpMyAdmin 5.0.0 的配置文件是 config.inc.php,位于安装目录:
cd /www/server/phpmyadmin/
如果没有此文件,复制示例文件:
cp config.sample.inc.php config.inc.php
编辑 config.inc.php,找到以下部分并修改:
$i = 0;
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['auth_type'] = 'config';
添加多个服务器(可选):
$i++;
$cfg['Servers'][$i]['host'] = '192.168.1.2';
$cfg['Servers'][$i]['user'] = 'user2';
$cfg['Servers'][$i]['password'] = 'pass2';
如果希望在登录页面选择服务器,添加:
$cfg['AllowArbitraryServer'] = true;
保存文件并重启 Web 服务器(Apache/Nginx):
sudo systemctl restart apache2
sudo systemctl restart nginx
打开浏览器,访问 phpMyAdmin:
http://your_phpmyadmin_server_ip/phpmyadmin