'find server ip by sql

How can I get server ip (host) by a MySQL query? an sql like this:

SELECT @@SERVERIP

I want to connect to my db by netbeans, and I can't use 'localhost' for host.

thanks



Solution 1:[1]

It's simple try this.

You can get the[hostname][instancename] by:

SELECT @@SERVERNAME;

To get only the hostname when you have hostname\instance name format:

SELECT LEFT(ltrim(rtrim(@@ServerName)), Charindex('\', ltrim(rtrim(@@ServerName))) -1)

Alternatively as @GilM pointed out:

SELECT SERVERPROPERTY('MachineName')

Solution 2:[2]

no you cannot here you can read from this thread :

http://lists.mysql.com/mysql/224556

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ravi polara
Solution 2 LostMohican