php - 更改 phpmyadmin 中的配置文件

标签 php mysql phpmyadmin

我已在此位置 /usr/share/phpmyadmin 安装了 phpmyadmin。数据库正在本地主机上运行。因此,我可以从 phpmyadmin 访问数据库,无需任何更改。我想将 localhost 更改为不同的主机或添加其他主机。

为此,我尝试更改 config.inc.php 文件并添加以下代码:

$i++;
$cfg['Servers'][$i]['host']          = 'xxx-east-1.rds.amazonaws.com';
$cfg['Servers'][$i]['port']          = '3306';
$cfg['Servers'][$i]['socket']        = '';
$cfg['Servers'][$i]['connect_type']  = 'tcp';
$cfg['Servers'][$i]['extension']     = 'mysql';
$cfg['Servers'][$i]['compress']      = FALSE;
$cfg['Servers'][$i]['auth_type']     = 'config';
$cfg['Servers'][$i]['user']          = 'xxx';
$cfg['Servers'][$i]['password']      = 'xxx';

但是,它没有与该主机连接。我应该在哪里更改此信息?

我注意到的一件奇怪的事情是,当我删除 config.inc.php 时,phpmyadmin 仍在工作。但是,可能是因为本地主机默认设置。

最佳答案

假设这是您在 phpMyAdmin 中的原始本地主机设置

$i++;
$cfg['Servers'][$i]['verbose'] = 'MySQL localhost';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = 3306;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';

您所做的就是添加另一个 block 来设置另一个可选连接

$i++;
$cfg['Servers'][$i]['verbose'] = 'MySQL on Amazon';
$cfg['Servers'][$i]['host'] = 'xxx-east-1.rds.amazonaws.com';
$cfg['Servers'][$i]['port'] = 3306;
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';

但是您应该检查您的远程 Amazon MySQLServer 是否使用端口 3306 作为标准,并且存在允许从远程位置连接的用户帐户设置。

And of course restart Apache after making this change.

关于php - 更改 phpmyadmin 中的配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45741382/

相关文章:

php - 正则表达式模式提取引号

javascript - 通过 Javascript 加载警报窗口后 HTML 字体大小发生变化

mysql - 如何在 mysql 中的 group by 结果后使用 where 子句

mysql - puppetlabs 仪表板模块中已弃用 mysql::server 模块,如何修复?

php - 如何从 php 获取 JSON 数据并显示到 android 中的 textview?

PHP MySQL 没有从数据库中获取任何内容

php - 带索引的 MySQL 查询优化器

php - 用逗号代替点的十进制数(php 和 sql)

php - Laravel - 从 DB::table()->insert 访问一个值

php - 配置 php 桌面 chrome 以允许它连接到 sql server