#首 先要保证远端数据库所在服务器防火墙是允许联入状态。
例如windows xp自带的防火墙开启时是不允许联入的。修改方法如下:
1.关闭防火墙。(安全性降低)
2.在开启状态时添加端口:3306,名字随便。(注:3306是mysql默认的连接端口。)
#另外需要修改远端mysql数据库的权限。
1.如果安装了phpMyadmin ,使用这个程序,添加一个新用户,赋予连接权限。注意在填写主机时要用”文本 域 “选项,并输入允许的ip地址。
2.如果没有安装phpMyadmin,使用命令添加用户:
CREATE USER 'root'@ '192.168.1.123' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B';
GRANT ALL PRIVILEGES ON * . * TO 'root'@ '192.168.1.123' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B'
WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
3.修改本地的phpMyadmin 配置:config.inc.php
在本地连接的后面添加要连接的ip配置
$i++;
$cfg['Servers'][$i]['host'] = '192.168.1.10';
$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();
之后就可以连接了