Home / Blog / 编程语言
Tech · 编程语言 · PHP

phpMyAdmin教程

H by Haofly
· 2016-08-03 · updated 2017-06-13 · 26 views

安装

CentOS 6.4安装phpMyAdmin

Ubuntu安装

# apache
sudo apt-get install phpmyadmin apache2-utils
## vim /etc/apache2/apache2.conf,添加如下一行
Include /etc/phpmyadmin/apache.conf

连接多个主机的配置

参考文章 配置如下:

  1. 将phpMyAdmin根目录下的config.sample.inc.php,重命名为config.inc.php

  2. 修改config.inc.php文件,添加如下内容:

     $connect_hosts = array(
         1 => array(
             "host"	=> "127.0.0.1",
             "port"	=> "3307",
             "socket"=> "/tmp/mysql.sock2",
             "user"	=> "root",
             "password"	=> "mysql",
             "connect_type"	=> "socket"
             ),
         2 => array(
             "host"	=> "127.0.0.1",
             "port"	=> "3309",
             "user"	=> "root",
             "password"	=> "mysql",
             "connect_type"	=> "tcp"
             )
         );
    
     for ($i=1;$i<=count($connect_hosts);$i++){  
         $cfg['Servers'][$i]['auth_type'] = 'cookie';  
         $cfg['Servers'][$i]['host'] = $connect_hosts[$i]['host'];   //修改host  
         $cfg['Servers'][$i]['connect_type'] = $conenct_hosts[$i]['connect_type'];  
         $cfg['Servers'][$i]['port'] = $connect_hosts[$i]['port'];
         if (array_key_exists('socket', $connect_hosts[$i])){
         $cfg['Servers'][$i]['socket'] = $conenct_hosts[$i]['socket'];
         }
         $cfg['Servers'][$i]['compress'] = false;  
         $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']; //密码  
         $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';  
     }
  3. 重启apache

TroubleShooting

  • 如果出现#2002 无法登录 MySQL 服务器错误,可能是地址填写的是localhost而不是127.0.0.1所致
Haofly · 豪翔天下 · 2016-08-03

评论 · Comments

评论由 Giscus 提供,需用 GitHub 账号登录;留言会同步到这个仓库的 Discussions 里。