zoukankan      html  css  js  c++  java
  • 链接多个数据库的方法

    把下面的代码 写到 phpmyadmin的文件里的config.inc.php 文件某处(见下面有说那里)

    $connect_hosts = array(
    '1'=>array(
    "host" => "localhost", //本地服务器
    "user" => "root",
    "password" => ""
    ),
    '2' => array(
    "host" => "服务器IP", //服务器1
    "user" => "username",
    "password" => "pwd"
    ),
    '3' => array(
    "host" => "服务器ip", //服务器2
    "user" => "username",
    "password" => "pwd"
    )
    );

    for ($i=1;$i<=count($connect_hosts);$i++) {

      /* Authentication type */
      $cfg['Servers'][$i]['auth_type'] = 'cookie';
      /* Server parameters */
      $cfg['Servers'][$i]['host'] = $connect_hosts[$i]['host']; //修改host
      $cfg['Servers'][$i]['connect_type'] = 'tcp';
      $cfg['Servers'][$i]['compress'] = false;
      /* Select mysqli if your server has it */
      $cfg['Servers'][$i]['extension'] = 'mysql';
      $cfg['Servers'][$i]['AllowNoPassword'] = true;
      $cfg['Servers'][$i]['user'] = $connect_hosts[$i]['user']; //修改用户名
      $cfg['Servers'][$i]['password'] = $connect_hosts[$i]['password']; //密码
      /* rajk - for blobstreaming */
      $cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
      $cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
      $cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
      $cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';

    }

    替换位置

    这里需要注意:  (下面这个不用管也行)
    (1)for循环的时候,i102′i = 0’,记得注释掉。也就是注释掉无关的代码

     后记:

    找到phpmyadmin文件夹下面的config.sample.inc.php,重命名为config.inc.php 直接在这个文件下面加上,多个数据库的代码,然后覆盖回原来的config.inc.php ,重启服务,即可

    参考: https://blog.csdn.net/ljfphp/article/details/78717355

  • 相关阅读:
    01Game
    面试题
    面试题
    面向对象笔记
    1212作业
    12011作业
    1210作业
    1206作业
    1205作业
    1204作业
  • 原文地址:https://www.cnblogs.com/kaibindirver/p/10446831.html
Copyright © 2011-2022 走看看