Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find MySQL ip on localhost?

Tags:

mysql

I am running my MySQL database on my machine, how do I get the ip of that MySQL server? I have already tried getting the ip of the machine but that doesn't work. I am running on Windows 8 OS on my machine and what I'm trying to do is connect a web page to my MySQL database which is on the MySQL server. They are not on the same network.

like image 712
GapplesPvP Avatar asked Dec 15 '22 07:12

GapplesPvP


1 Answers

Use status in mysql prompt

mysql> status

OR

 mysql> \s

Other ways,

SELECT SUBSTRING_INDEX(USER(), '@', -1) AS ip,  @@hostname as hostname, @@port as port, DATABASE() as current_database;

SELECT * FROM information_schema.GLOBAL_VARIABLES where VARIABLE_NAME like 'hostname';

SELECT host FROM information_schema.processlist WHERE ID=connection_id();

Will give you the host name (or IP address if name resolution is not enabled, which it is usually not) connecting to the mysql server on the current connection.

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: https://dev.mysql.com/doc/refman/8.0/en/show-variables.html.

like image 89
Amitesh Bharti Avatar answered Dec 22 '22 00:12

Amitesh Bharti