Hướng dẫn get ip mysql

I have a free domain running at x10hosting [x10.bz], and I want to find out the IP Address of my MySQL host for it, so I can contact the MySQL database from another host. I've already added that host to the access list, but now I need to find out the IP Address of the MySQL host. How can I find this out? x10 is using cPanel X and PHPMyAdmin.

Nội dung chính

  • How do I find my MySQL database IP address?
  • How do I find the location of MySQL?
  • How do I find MySQL host and port?
  • How do I find the hostname of my MySQL database?

peterh

4,91413 gold badges29 silver badges44 bronze badges

asked Apr 6, 2010 at 6:18

Deniz ZoetemanDeniz Zoeteman

7212 gold badges8 silver badges18 bronze badges

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

answered Apr 6, 2010 at 7:14

4

You may try this if using MySQL 5.7 version

 mysql> SELECT SUBSTRING_INDEX[USER[], '@', -1] AS ip,  @@hostname as hostname, @@port as port, DATABASE[] as current_database;
+-----------+-----------------+------+------------------+
| ip        | hostname        | port | current_database |
+-----------+-----------------+------+------------------+
| localhost | host001         | 3306 | kakadba          |
+-----------+-----------------+------+------------------+
1 row in set [0.00 sec]

Or just write status in mysql prompt

mysql> \s

OR

 mysql> status

answered Jul 6, 2016 at 7:53

koustuvkoustuv

6567 silver badges11 bronze badges

Using PHPMyAdmin all variables are already listed if you click "home" > "MySQL system variables". You can use the find feature of your browser to search for the "hostname" and the "port" variables or scroll to them. It's listed in alphabetical order. No mucking about with queries if you are a non technical person.

answered Oct 10, 2014 at 17:52

DanielDaniel

711 silver badge1 bronze badge

Once you are in phpMyAdmin, look for the horizontal menu:

Dashboard | Sql | Status | Users ...etc

Click on Variables.

Here you will find all the variables for mySql server. You can try the search box for specific variables.

Good Luck.

answered Apr 27, 2016 at 6:35

AakashAakash

1413 bronze badges

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.

asked Apr 17, 2016 at 16:33

GapplesPvPGapplesPvP

511 gold badge1 silver badge3 bronze badges

7

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

answered Aug 13, 2018 at 9:03

Amitesh BhartiAmitesh Bharti

11.6k6 gold badges56 silver badges54 bronze badges

1

Preety old, but I ran into the same problem today and maybe it helps someone else. I find out how to use the MySQL syntax:

SHOW VARIABLES

Where, to filter your hostname, it would be:

SHOW VARIABLES WHERE Variable_name = 'hostname'

answered May 15, 2017 at 1:37

Dimas PanteDimas Pante

2,41821 silver badges29 bronze badges

Better way is:

If you are using Debian/Ubuntu Linux one file is located at /etc/mysql/my.cnf location.

However, in my installation I see:

/etc/mysql/mariadb.conf.d/50-server.cnf

Just onpen this file: nano search for: [mysqld]

user                    = mysql
...
.
.
.
bind-address             = 127.0.0.1

bind-address is your local-host address. 127.0.0.1 is the IP address of local machine on which Mysql server is hosted. It can be something else like: 10.208.8.122, Its still is teh IP address of local machine but for remote conenction. So one can reach this Mysql server through this IP

answered Nov 10, 2020 at 9:28

yogenderyogender

3372 silver badges5 bronze badges

If you are connecting to the database from the machine where the SQL server is installed then you will be able to access it via localhost on port 3306

If you are accessing it through a different machine, then connect to the IP address of the machine where the SQL serve is installed on port 3306

answered Apr 17, 2016 at 17:16

0xtvarun0xtvarun

6986 silver badges18 bronze badges

4

First you have to find out your external IP to allow external web server to connect to your local MySQL server.

User one of these services:

  • //www.knowmyip.com/
  • //whatismyipaddress.com/es/mi-ip
  • //www.iplocation.net/find-ip-address

After that, you need to allow this "outside" access. You will need your router admin access [web, SSH or directly by USB]. Open desired port, by default 3306. Redirect it to your local machine ip [it usually is like 192.xx.xx.xx]

Once you have configured your router to connect MySQL port to your internal-lan machine, you need to open this port in your machine. For that you will need to:

  • Check System firewall [windows firewall, Linux iptables or so one]. And check possible 3rd party firewalls installed.

  • Allow your local MySQL server to accept external requests, some installation does not accept it "out-of-the-box". Access to My.cnf file and search the directive to allow external connections. It's well explained here: //www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

  • Finally, you have to bind external permissions to user you will identify with. Here you will find a good explanation: How to allow remote connection to mysql

If everyting went OK then you will be able to serve MySQL service from your local machine, through your router to the external world.

Get lucky!

answered Apr 17, 2016 at 17:25

manuelbcdmanuelbcd

2,6801 gold badge23 silver badges37 bronze badges

How do I find my MySQL database IP address?

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.

How do I find the location of MySQL?

Resolution.

Open up MySQL's configuration file: less /etc/my.cnf..

Search for the term "datadir": /datadir..

If it exists, it will highlight a line that reads: datadir = [path].

You can also manually look for that line. ... .

If that line does not exist, then MySQL will default to: /var/lib/mysql..

How do I find MySQL host and port?

Another way to find out the port which MySQL Server is using on Windows is , Go to my. ini file that is MySQL configuration file and you can check the port. To find the my. ini file for MySQL Server, you can go to services and then go to properties.

How do I find the hostname of my MySQL database?

How to Find MySQL Hostname When It's Not Localhost.

Ask Support. It might seem obvious, but often the simplest tactic is to just reach out to the support team behind the database that you're trying to connect to. ... .

Use phpMyAdmin. ... .

Use the Domain Associated With the Database Server..

Chủ Đề