[文章作者:张宴 本文版本: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: , ,
技术大类 » 数据库技术 | 评论(53) | 引用(0) | 阅读(71781)
coach88888888 Email
2012-8-13 17:21
Coach Factory Outlet offer excellent, elegant coach products in order to generate room for your new collections.They're purchased more quickly that you may at any time imagine.Most significantly, the coach designer purses of Coach Factory Online industry won't deteriorate your individual fashions at all. Rather they would immediately change your overall looks marvelously.I find it all very odd But this is no different than Coach Outlet Online any other company that has an outlet presence and really doesn’Coach Outlet Store t explain it to the customer.By the fashion, novel appearance, sophisticated technology, superior quality, Coach Outlet won domestic and international customers, their products exported to the Middle East, Southeast Asia and other regions.
XYD
2012-9-16 14:27
牛人!!!
North Face Pink Ribbon Denali Email Homepage
2012-10-31 12:12
North Face Pink Ribbon lightweight idea suit all climbers require, diminish your pressure. Unlike other brand, North Face Pink Ribbon Denali mainly display the fashionable, leisure,movement and personalized.
North Face Pink Ribbon Denali Email Homepage
2012-10-31 12:13
Ideal for trekking or cycling, this North Face Denali combines extreme breathability and durable wind protection with minimum weight and pack volume. Discount North Face Jackets are only made for winter, which designed so warm and heavy.
晨池 Email
2012-11-20 21:20
好文章!多谢!
bzcvsd
2012-11-28 16:18
gfdgd
2012-11-28 16:25
昵称
2013-1-11 17:21
太马粪了
苦作舟 Homepage
2013-1-12 20:22
(苦作舟 )新版的phpmyadmin不行,phpMyAdmin - Error
Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.
FGWAET
2013-1-29 16:42
买轴承就到:www.jkzhoucheng.cn
camika Email
2018-12-6 18:12
For you have a new, average or average article you must be understood and try to be more in search, I am very excited with your article this page, really absolute.run 3
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]