Хост базы данных как узнать

Your MySQL hostname defines the location where your MySQL database is hosted. If you want to connect to your database, you need to specify the MySQL hostname so that your application knows where to connect.
In most situations, including hosting a WordPress site at Kinsta, your MySQL hostname will be localhost.
Essentially, this means that your MySQL database is running on the same server as the application that you’re working with (like your WordPress site). We have a detailed article that explains the concept of localhost and how it applies to WordPress.
If you host your WordPress site at Kinsta, all you normally need to know is that your database hostname is localhost. But if you’d like to learn more about the topic, or need to connect remotely to a database, continue reading for a deeper explanation.
What Is MySQL Hostname?
The MySQL hostname defines the location of your MySQL server and database. If you want to connect to the information in a MySQL database, you’ll need to know the hostname. Again, the hostname is usually localhost, which indicates that the database is running on the same server as your application (e.g. WordPress).
On a WordPress site, your MySQL hostname is defined in your site’s wp-config.php file.
If you were to connect to your WordPress site’s server via FTP and open your wp-config.php file, you will see your MySQL hostname defined on the following line:

How to find MySQL hostname in WordPress
On most WordPress installs, the value will be defined as localhost.
How Do I Find the MySQL Hostname?
Let’s go through how to find your database’s hostname in common situations.
How Do I Find MySQL Hostname in Kinsta?
At Kinsta, your database’s hostname is localhost for all of your WordPress sites.
If you need to connect remotely to your WordPress site’s database at Kinsta, you can follow our tutorial on remote database access.
How Do I Find MySQL Hostname in cPanel?
By default, cPanel also uses localhost for its MySQL hostname.
However, it is possible for hosting providers to specify a remote database server instead. Unfortunately, there’s no default way to learn this from inside cPanel (unless your host has added their own tool).
If localhost isn’t working for you, your best bet is to reach out to your host’s support.
You can also try using the domain name that’s associated with your cPanel account or use intoDNS to find the IP address associated with the domain’s A record and use that IP address as your hostname:
Sign Up For the Newsletter
Want to know how we increased our traffic over 1000%?
Join 20,000+ others who get our weekly newsletter with insider WordPress tips!

How to find the domain IP address
Or, you can use phpMyAdmin, which is the next option.
How Do I Find phpMyAdmin Hostname?
phpMyAdmin lets you view and edit your database. It also provides you with information on your MySQL hostname.
When you open phpMyAdmin, look for the Server information from the Database server box. You can see how, at Kinsta, phpMyAdmin indicates that the MySQL server is localhost:

MySQL server in phpMyAdmin
If you need to connect remotely using the IP address/domain of your MySQL database, you can open the Variables menu from your phpMyAdmin homepage and search for “hostname” to find the actual domain or IP address of the database server:

How to find hostname variable in phpMyAdmin
You can access the phpMyAdmin homepage by clicking on the logo in the top-left corner.
Again, if you’re specifically looking to connect to your database remotely at Kinsta, we have a dedicated article showing you how to set that up.
In case you need to find MySQL port number follow this guide.
How to Find MySQL Hostname When It’s Not Localhost
In almost all situations, your MySQL will be localhost, especially with WordPress. However, if you’re trying to connect remotely to a MySQL database, the hostname will not be localhost.
If your hostname isn’t localhost, here are some tactics to discover it.
1. 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. They should be able to provide you with the MySQL hostname.
2. Use phpMyAdmin
If you have access to phpMyAdmin, you can follow the method from the previous section to use phpMyAdmin to find your MySQL hostname by looking up the hostname variable.
3. Use the Domain Associated With the Database Server
If you know the domain name associated with your database server (e.g. the domain name associated with cPanel), you can look up the domain name’s A record using intoDNS to find the IP address for your MySQL server.
Summary
Your hostname defines the location of your MySQL database server. In most cases, especially when working with WordPress sites, you can use localhost as your hostname.
However, if you need to connect remotely to a database, you will need to find the IP address of your MySQL host to connect remotely.
Save time, costs and maximize site performance with:
- Instant help from WordPress hosting experts, 24/7.
- Cloudflare Enterprise integration.
- Global audience reach with 34 data centers worldwide.
- Optimization with our built-in Application Performance Monitoring.
All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to find the plan that’s right for you.
Hand-picked related articles

How to Do a WordPress Migration on Your Own (With No Downtime)

A Beginner’s Guide to WordPress Database: What It Is and How to Access It

How to Backup MySQL Database (2 Incredibly Easy Methods)
Subscribe to our Newsletter
Get premium content from an award-winning WordPress hosting platform
Sign Up For the Newsletter
Log in to MyKinsta or take a sneak peek with a demo account
© 2022 Kinsta Inc. All rights reserved. Kinsta® and WordPress® are registered trademarks. Legal information.
How do I find out my MySQL URL, host, port and username?
I need to find my MySQL username. When I open the MySQL command line client, it only asks me for my password. I don’t remember my username. And for connectivity with JDBC, I need the URL, host and port number. Where do I find all of these?
12 Answers 12
If you’re already logged into the command line client try this:
It will output something similar to this:
In my example above, I was logged in as root from localhost .
To find port number and other interesting settings use this command:
If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client —
It will give you the port number on which MySQL is running.
If you want to know the hostname of your Mysql you can use this query on MySQL Command line client —
It will give you the hostname for mysql.
If you want to know the username of your Mysql you can use this query on MySQL Command line client —
It will give you the username for mysql.
![]()
For example, you can try:
![]()
If you don’t know the exact variable name use like , as the result may contain more than 500 rows:
![]()
If using MySQL Workbench, simply look in the Session tab in the Information pane located in the sidebar.

![]()
![]()
Easiest way is probably using command status; In the output you’ll find database, user, host and port:
![]()
If you use phpMyAdmin, click on Home , then Variables on the top menu. Look for the port setting on the page. The value it is set to is the port your MySQL server is running on.
Here are the default settings
default-username is root
default-password is null/empty //mean nothing
default-url is localhost or 127.0.0.1 for apache and
localhost/phpmyadmin for mysql // if you are using xampp/wamp/mamp
default-port = 3306
![]()
For Example in my case : karola-pc is the host name of the box where my mysql is running. And it my local PC host name.
If it is romote box than you can ping that host directly if, If you are in network with that box you should be able to ping that host.
If it UNIX or Linux you can run «hostname» command in terminal to check the host name. if it is windows you can see same value in MyComputer-> right click -> properties ->Computer Name you can see ( i.e System Properties)
Как узнать имя сервера MySQL на хостинге?
Имя MySQL сервера может понадобиться при установке системы управления сайтом. Для того, чтобы узнать имя Вашего MySQL сервера на хостинге необходимо перейти в раздел «Хостинг» — «MySQL».

На скриншоте это адрес «db6.ipipe.ru»
Если базы данных нет?
Чтобы добавить базу данных, на этой же странице нажмите «Добавить». В открывшемся окне Вы можете задать желаемый пароль, кодировку и комментарий:

После того, как будет нажата кнопка «Применить», создастся новая база данных с соответствующим уведомлением:

Вы можете посмотреть все интересующие данные для свежесозданной базы данных – логин, пароль, сервер, имя БД и комментарий.
Как мне узнать мой MySQL URL, хост, порт и имя пользователя?
Мне нужно найти свое имя пользователя MySQL. Когда я открываю клиент командной строки MySQL, он запрашивает только мой пароль. Я не помню свое имя пользователя. А для подключения к JDBC мне нужен URL, номер хоста и номер порта. Где я могу найти все эти данные?
8 ответов
Если вы уже вошли в клиент командной строки, попробуйте следующее:
Он выведет что-то похожее на это:
В моем примере выше я вошел в систему как root из localhost .
Чтобы найти номер порта и другие интересные настройки, используйте эту команду:
Если вы хотите узнать номер порта вашего локального хоста, на котором работает Mysql, вы можете использовать этот запрос для клиента командной строки MySQL —
Он предоставит вам номер порта, на котором работает MySQL.
Если вы хотите узнать имя хоста вашего Mysql, вы можете использовать этот запрос для клиента командной строки MySQL —
Он предоставит вам имя хоста для mysql.
Если вы хотите узнать имя пользователя вашего Mysql, вы можете использовать этот запрос для клиента командной строки MySQL —
Он даст вам имя пользователя для mysql.
Например, вы можете попробовать:
Если вы не знаете точное имя переменной, используйте like , так как результат может содержать более 500 строк:
Для примера в моем случае: karola-pc — это имя хоста, в котором работает мой mysql. И это имя моего локального ПК.
Если это поле со списком, то вы можете напрямую прогнать этот узел, если: Если вы находитесь в сети с этим полем, вы сможете выполнить ping с этого хоста.
Если он UNIX or Linux you can run «hostname» command в терминале для проверки имени хоста. если это окна, вы можете увидеть одно и то же значение в MyComputer-> right click -> properties ->Computer Name , вы можете увидеть (например, Свойства системы)