38

I have access to my server's phpmyadmin. But how can I find that mysql's Ip address from phpmyadmin. My webserver and mysql is using different IPs.

Is there any way to find this out?

Crd007
  • 473
  • 1
  • 7
  • 16
  • 1
    http://stackoverflow.com/questions/8330898/find-server-ip-by-sql – Christian Feb 24 '13 at 23:36
  • 2
    If one of the answers below answered your question, the way this site works works, you'd "accept" the answer, more here: ***[What should I do when someone answers my question?](http://stackoverflow.com/help/someone-answers)***. But only if your question really has been answered. If not, consider adding more details to the question. – Blue Jan 17 '18 at 14:52
  • 1
    @FrankerZ This question was asked 8 years ago around 7 years ago when you wrote you reply... he was seen for last time in 2012 you didnt really expect him to come back and accept an anwser? – Freddy789 Aug 22 '19 at 13:31

6 Answers6

48

The SQL query SHOW VARIABLES WHERE Variable_name = 'hostname' will show you the hostname of the MySQL server which you can easily resolve to its IP address.

SHOW VARIABLES WHERE Variable_name = 'port' Will give you the port number.

You can find details about this in MySQL's manual: 12.4.5.41. SHOW VARIABLES Syntax and 5.1.4. Server System Variables

Waruna Manjula
  • 3,067
  • 1
  • 34
  • 33
11

MySQL doesn't care what IP its on. Closest you could get would be hostname:

select * from GLOBAL_variables where variable_name like 'hostname';
Louis
  • 302
  • 2
  • 4
5
select * from SHOW VARIABLES WHERE Variable_name = 'hostname';
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
ted
  • 87
  • 1
  • 1
  • 1
    If someone is trying to run this in phpMyAdmin, remove the 'select * from'. It should simply be: `SHOW VARIABLES WHERE Variable_name = 'hostname'` – jiminy Mar 05 '22 at 18:13
3

The server's address is stored in config.php

fvu
  • 32,488
  • 6
  • 61
  • 79
1

As an alternative, since you know the hostname, resolve the database server IP via hostname from the web server.

http://php.net/manual/en/function.gethostbyname.php

Spechal
  • 2,634
  • 6
  • 32
  • 48
-2

You can ssh to your server and run this command

 ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

It worked for me..