473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Retrieving MySQL server's port value with PHP

How can I programattically retrieve MySQL server's port value through
PHP?

Mar 18 '07 #1
6 4140
Mitesh wrote:
How can I programattically retrieve MySQL server's port value through
PHP?
Did you try

ini_get('mysql.default_port');

(or, if you have mysqli installed...)

ini_get('mysqli.default_port');

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 18 '07 #2

Jerry Stuckle wrote:
Mitesh wrote:
How can I programattically retrieve MySQL server's port value through
PHP?

Did you try

ini_get('mysql.default_port');

(or, if you have mysqli installed...)

ini_get('mysqli.default_port');
Thanx Jerry for the reply:

This returns the default port value. But when the MySQL server is
installed the app that runs after the installation lets the user
configure the MySQL port. Now I need to access this port value through
the PHP. My PHP script only works for the port value that is pre-
defined. So when the user again does configuration and changes the
port value, my PHP script (which calls my sql functions) no longer
works.

I think I have no alternative than to open the MySQL ini file through
PHP and search for the "port" text and retrieve it's value.

Mar 18 '07 #3
Mitesh wrote:
Jerry Stuckle wrote:
>Mitesh wrote:
>>How can I programattically retrieve MySQL server's port value through
PHP?
Did you try

ini_get('mysql.default_port');

(or, if you have mysqli installed...)

ini_get('mysqli.default_port');

Thanx Jerry for the reply:

This returns the default port value. But when the MySQL server is
installed the app that runs after the installation lets the user
configure the MySQL port. Now I need to access this port value through
the PHP. My PHP script only works for the port value that is pre-
defined. So when the user again does configuration and changes the
port value, my PHP script (which calls my sql functions) no longer
works.

I think I have no alternative than to open the MySQL ini file through
PHP and search for the "port" text and retrieve it's value.
If you change the port in the MySQL configuration, you should also
change it in your php configuration. That's what they're there for.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 18 '07 #4
>I think I have no alternative than to open the MySQL ini file through
>PHP
Hopefully, you do not have permission necessary to do that.
It's going to be especially difficult if the server is on a different
machine from PHP.

You also don't know which MySQL ini file is actually being used by the
instance of MySQL you want to access.
>and search for the "port" text and retrieve it's value.

Mar 18 '07 #5
Thanx Jerry:

Fine point

Gordon Burditt wrote:
I think I have no alternative than to open the MySQL ini file through
PHP

Hopefully, you do not have permission necessary to do that.
It's going to be especially difficult if the server is on a different
machine from PHP.
Thanx Gordon:

Ah! I didn't supply enough information. Actual the above is not a
problem for me right now. But can be in future version of the app.
Currently the PHP is only accessed by the administrator and the
administrator and the servers (both MySQL and Apache) is on the same
machine.

But in the future spec version 2.0 I do see a requirement that the
administrator should be able to log on into the system from any one
of the LAN machines. So that can be a problem.

I think Jerry's way should solve this problem too. The configuration
exe is run on the machine where the servers are located.

Mar 19 '07 #6
Mitesh wrote:
Thanx Jerry:

Fine point

Gordon Burditt wrote:
>>I think I have no alternative than to open the MySQL ini file through
PHP
Hopefully, you do not have permission necessary to do that.
It's going to be especially difficult if the server is on a different
machine from PHP.

Thanx Gordon:

Ah! I didn't supply enough information. Actual the above is not a
problem for me right now. But can be in future version of the app.
Currently the PHP is only accessed by the administrator and the
administrator and the servers (both MySQL and Apache) is on the same
machine.

But in the future spec version 2.0 I do see a requirement that the
administrator should be able to log on into the system from any one
of the LAN machines. So that can be a problem.

I think Jerry's way should solve this problem too. The configuration
exe is run on the machine where the servers are located.
One word of caution. Other machines are going to expect MySQL to be
using port 3306. Their PHP installations won't be affected by the
change to the original php.ini. So if you're going to be accessing
MySQL from PHP (or any other language, for that matter) on a different
port, you'll have to specify it in the mysql_connect() (or equivalent) call.

I just find it easier to go ahead and leave it on 3306. And if you're
thinking of moving it for security reasons - forget it. It takes about
30 seconds to find every open port on your system - and the script is
only a half dozen lines long. It might take another minute (and 5 lines
of script) to determine which port MySQL is actually using.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: philippe Tressard | last post by:
Hi, I've 2 instances of apache 1.3.27 with php 4.2.3 and mysql 3.23.42 running on the same server. The 1st apache listens the port number 80 and communicates with the 1st mysql with the...
0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
16
by: MLH | last post by:
Using MS Access, I have attached to MySQL servers in other states and other countries on the other side of my router. But when I use the MySQL ODBC driver 3.51 to connect to a MySQL server on my...
1
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer...
1
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work....
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
1
by: PowerLifter1450 | last post by:
I've been having a very rough time installinig mySQL on Linux. I have been following the instructions form here: http://www.hostlibrary.com/installing_apache_mysql_php_on_linux Everytime I get to...
1
by: polycom | last post by:
Hi, I am coding a mysql health check script. The logic is to execute the commands (only once)show status,show slave status,show variables and fetch the variable name and value in a hash refer or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.