[文章作者:张宴 本文版本: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) | 阅读(93123)
shzz Email
2022-7-17 00:22
I want to say thanks to you. I have bookmark your site for future updates.  online dealings
shz Email
2022-7-17 00:22
I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!  online dealings
shz Email
2022-7-17 00:26
Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.  online dealings
shz Email
2022-7-17 00:29
This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea.  online dealings
Salima Email
2022-12-20 14:31
Poker Online hadir untuk anda sebagai situs judi poker online terpercaya poker88 link alternatif adalah solusi bagi anda para pecinta permainan kartu online. Mudah diakses dan dimainkan kapanpun dan dimanapun, yang bisa di download di gadget kesayangan anda. . . . Situs nagapoker io juga sudah menyiapkan teknologi tertinggi dan termodern untuk Anda agar lebih nyaman saat bermain, dijamin tidak lag. Sebagai salah satu situs judi online terbaru dan teraman, keamanan anda selama bermain menjadi prioritas yang akan selalu kami jaga. 100% Tanpa robot, Pemain vs Pemain.
siyore4070 Email Homepage
2023-7-12 18:40
Hello! Someone in my Facebook group shared this site with us so I came to take a look. I'm definitely enjoying the information. I'm book-marking and will be tweeting this to my followers! Excellent blog and brilliant design and style. the point click care loginthe point click care login
Lucky cola
2024-2-7 16:05
Challenge your friends and emerge as the ultimate champion.  Lucky cola
meeloun Email
2024-4-7 15:24
对于英国网课代修       http://www.wangkedaixiu.com/wkdx/uk/         服务的需求逐渐增长。国际留学生面临着语言、文化等多方面的障碍,而一些本地学生也因为专业知识的限制或时间压力而需要外部帮助。英国网课代修服务的兴起迎合了这一需求,为学生提供了更多选择,帮助他们更好地完成学业。
分页: 4/4 第一页 上页 1 2 3 4 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]