473,775 Members | 2,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving MySQL server's port value with PHP

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

Mar 18 '07 #1
6 4155
Mitesh wrote:
How can I programatticall y 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*******@attgl obal.net
=============== ===
Mar 18 '07 #2

Jerry Stuckle wrote:
Mitesh wrote:
How can I programatticall y 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 programatticall y 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*******@attgl obal.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*******@attgl obal.net
=============== ===
Mar 19 '07 #7

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

Similar topics

0
2178
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 socket /var/mysql/mysql1.sock (i've also defined the port 3306) The 2nd apache listens the port number 8080 and communicates with the 2nd
0
3680
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 mysql- connector-java-2.0.14-bin.jar in commons/lib. The application runs normally, and usually about once or twice a day I get this exception org.apache.commons.dbcp.DbcpException: java.sql.SQLException: Server configuration denies access to data...
0
3948
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 version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
16
27923
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 own LAN, the driver tells me it cannot make the connection. Here are the ODBC driver connection parms: Data Source Name: (free field - name my "my linux box" will do nicely) Host/Server Name (or IP) - something like MSQLUserName@ServerName.net...
1
3379
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 uses his own php shopping cart to receive customer orders. The configuration was done via cPanel with no external modifications - which produced no protests when built, ran and connected with no
1
2830
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. Despite entering the required lines to "my.ini" (the new my.cnf) through notepad AND MySQL Administrator, the cache does not work. So, today I took a peek at the 'Health' tab in MySQL Administrator.
15
4642
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
1
5285
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 #./configure it goes through all of the preparing tables and starting mysqlServer and daemon, but than immediaetly says "mysql ended" -- I try to do #make right after anyway, but I get the error "No targets specified and no makefile found" -- Any...
1
6851
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 any other fetch machanism and dynamically use the values to do calculation like the following threhold values($uptime > 10800) && (Handler_read_rnd_next > 4000) && ((100-(((Handler_read_rnd_next + Handler_read_rnd) / (##Handler_read_rnd_next +...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10270
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.