[文章作者:张宴 本文版本:v1.2 最后修改:2007.07.09 转载请注明出处:http://blog.zyan.cc]

需求背景:
  phpMyAdmin是一款不错的MySQL在线管理工具,但phpMyAdmin的cookie登录方式只能输入MySQL数据库的用户名和密码,而想更改MySQL服务器地址和端口则须修改其配置文件config.default.php。当拥有多台数据库服务器,每台服务器又在不同端口启动了多个MySQL服务,每次都修改配置文件就显得很麻烦,因此需要能够在登录界面直接输入MySQL服务器地址和端口的功能。

功能要求:
  假设phpMyAdmin的访问网址为http://192.168.1.25/phpmyadmin/,能够通过输入MySQL服务器地址、端口、用户名、密码登录远程MySQL服务器,对远程数据库进行管理。

修改后的phpMyAdmin登录入口截图:
点击在新窗口中浏览此图片

下载地址:http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=1848024

实现步骤:

1、打开“路径/phpmyadmin/libraries/config.default.php”,查找相关项并修改为以下内容:

2、打开“路径/phpmyadmin/index.php”,在文件最开头增加以下PHP代码:


3、打开“路径/phpmyadmin/libraries/auth/cookie.auth.lib.php”,查找“<!-- Login form -->”这行,在该行下方的第10行后(即“<?php } ?>”这行后)增加以下HTML代码:

图示:
点击在新窗口中浏览此图片


4、创建一个可以从任何IP地址远程连接的MySQL帐号sina

  MySQL默认的帐号为root,密码为空,只允许localhost登录,因此需要创建一个可以从任何IP地址远程连接的MySQL帐号,本例中创建的帐号为sina,密码为zhangyan。使用该帐号从phpMyAdmin登录后,别忘了在“权限”栏中修改密码。

(1)、Linux下的MySQL命令行客户端添加帐号示例:
A.登录使用默认3306端口的MySQL
引用
/usr/local/mysql/bin/mysql -u root -p


B.通过TCP连接管理不同端口的多个MySQL(注意:MySQL4.1以上版本才有此项功能)
引用
/usr/local/mysql/bin/mysql -u root -p --protocol=tcp --host=localhost --port=3307


C.通过socket套接字管理不同端口的多个MySQL
引用
/usr/local/mysql/bin/mysql -u root -p --socket=/tmp/mysql3307.sock


D.通过端口和IP管理不同端口的多个MySQL
引用
/usr/local/mysql/bin/mysql -u root -p -P 3306 -h 127.0.0.1


Enter password: (输入密码,如果密码为空,直接回车)
mysql> (在这儿输入以下的语句)
引用
GRANT ALL PRIVILEGES ON *.* TO 'sina'@'%' IDENTIFIED BY 'zhangyan';

如果提示信息为Query OK, 0 rows affected (0.01 sec),表示执行成功。

(2)、Windows下的MySQL命令行客户端添加帐号示例:
A.管理使用默认3306端口的MySQL
引用
d:\apmserv\mysql\bin\mysql.exe -u root -p


B.管理不同端口的多个MySQL
引用
d:\apmserv\mysql\bin\mysql.exe -u root -p --port=3307


Enter password: (输入密码,如果密码为空,直接回车)
mysql> (在这儿输入以下的语句)
引用
GRANT ALL PRIVILEGES ON *.* TO sina@"%";

如果提示信息为Query OK, 0 rows affected (0.01 sec),表示执行成功。

Tags: , ,



技术大类 » 数据库技术 | 评论(70) | 引用(0) | 阅读(95061)
700router
2007-4-13 18:36
你好,你的配置是否可以连接不用Ip的mysql数据库呢?比如
192.168.0.1安装phpmyadmin
用它来管理192.168.0.10、192.168.0.11,两天机器的mysql数据库。
我按照你的配置来配,每次登陆不管服务器地址和端口输入什么,都只能登陆本机mysql(192.168.0.1也有mysql)
注明:10,11的mysql在192.168.0.1上可以用myslq -uroot -p××× 方式登陆(远程登陆已经授权)
张宴 回复于 2007-4-13 22:26
您好。此配置就是为了方便连接不同IP的MySQL数据库的。
出现只能登录本机的情况可能是你的phpmyadmin配置文件中的MySQL地址还是默认的localhost,你可以打开“路径/phpmyadmin/libraries/config.default.php”,查找“localhost”,如果找到,替换为$_COOKIE["mysqlhost"];
(可参见步骤1)
张宴 Email Homepage
2007-7-6 19:56
下载本文所述修改过的phpmyadmin:
http://blog.s135.com/read.php/260.htm
董建农 Email Homepage
2007-9-7 11:53
梦网-发自梦研究者董建农
http://www.dongjiannongdream.zoomshare.com

2007. 9. 07. 北京
fox Email
2007-9-8 10:27
你好,我遇到的问题和上面的那位同志一样,sweat,我照着你的配置过两遍了还是不能打开我要配置的页面,出现的错误是:在服务器上找不到url
      上面的所有步骤我保证一个不差,我已经把config.default.php,   index.php  还有cookie.auth.lib.php都改,也,开了3306端口,建立了可以连接的账号
       可就是在phpmyadmin里,说在服务器上找不到url
        我用的是Debian,在putty下就能远程登陆
        请指点shy
阿权 Homepage
2008-3-12 22:16
我使用的 phpMyAdmin 2.6.4-pl4 一直都可以管理多个mysql数据库,可以直接记录在config.php里面,直接切换
wudi
2008-10-27 17:58
管理多个IP的MYSQL 用SQLyog Enterprise 好了
forward
2008-11-30 00:00
[D:\软件\系统工具\phpMyAdmin\libraries\auth\cookie.auth.lib.php:621] #1 PMA_auth_set_user() called at [D:\软件\系统工具\phpMyAdmin\libraries\common.inc.php:817] #2 require_once(D:\软件\系统工具\phpMyAdmin\libraries\common.inc.php) called at [D:\软件\系统工具\phpMyAdmin\index.php:42]
请问这是什么问题
Cross
2009-4-2 00:39
phpMyAdmin - 错误
无法载入 mysql 扩展,<br />请检查 PHP 配置

怎么解决?
storysky
2009-12-1 11:10
呵呵,很好玩的东西
gouxiongmao
2011-5-5 18:49
700路由和狐狸,你们的配置的修改是手工输入的吧?我建议你们按照张宴的代码直接复制粘贴,我刚开始也有你们的问题,后来发现因为我是手工修改的配置,我的好多地方的mysqlport都写成了mysqlhost,查半天没查出问题,后来又下载了张宴提供的那个下载版进行对比才发现问题的,现在我用的331版本的,很好用。所以强烈推荐直接复制粘贴张宴的代码!
中华 Homepage
2011-8-25 07:25
我的站www.xjdwx.com 数据库昨天又坏了
louis vuitton uk Email Homepage
2011-11-22 17:33
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
xiaoxiao Email
2011-12-15 17:37
君不见 AllowArbitraryServer 用的着这么麻烦么,宴哥。
aaaa
2012-3-6 20:34
fearbad
coach factory outlet Email Homepage
2012-5-17 10:24
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 10:24
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 10:24
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 10:24
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
分页: 1/4 第一页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]