Programing

MySQL URL, 호스트, 포트 및 사용자 이름을 어떻게 알 수 있습니까?

lottogame 2020. 7. 9. 08:23
반응형

MySQL URL, 호스트, 포트 및 사용자 이름을 어떻게 알 수 있습니까?


MySQL 사용자 이름을 찾아야합니다. MySQL 명령 행 클라이언트를 열면 비밀번호 만 묻습니다. 내 사용자 이름이 기억 나지 않습니다. 그리고 JDBC와의 연결을 위해서는 URL, 호스트 및 포트 번호가 필요합니다. 이 모든 것을 어디서 찾을 수 있습니까?


명령 행 클라이언트에 이미 로그인 한 경우 다음을 시도하십시오.

mysql> select user();

다음과 비슷한 결과가 출력됩니다.

+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.41 sec)

내 위의 예에서, I는 로그인 한 root에서 localhost.

포트 번호 및 기타 흥미로운 설정을 찾으려면 다음 명령을 사용하십시오.

mysql> show variables;

MySQL 이 실행중인 로컬 호스트포트 번호 를 알고 싶다면 MySQL Command line client 에서이 쿼리를 사용할 수 있습니다.

SHOW VARIABLES WHERE Variable_name = 'port';


mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.00 sec)

MySQL이 실행되는 포트 번호를 제공합니다.


MySQL호스트 이름 을 알고 싶다면 MySQL Command line client 에서이 쿼리를 사용할 수 있습니다.

SHOW VARIABLES WHERE Variable_name = 'hostname';


mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| hostname          | Dell  |
+-------------------+-------+
1 row in set (0.00 sec)

mysql의 호스트 이름을 제공합니다.


MySQL사용자 이름 을 알고 싶다면 MySQL Command line client 에서이 쿼리를 사용할 수 있습니다.

select user();   


mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql의 사용자 이름을 제공합니다.


예를 들어 다음을 시도 할 수 있습니다.

//If you want to get user, you need start query in your mysql:
SELECT user(); // output your user: root@localhost
SELECT system_user(); // --

//If you want to get port your "mysql://user:pass@hostname:port/db"
SELECT @@port; //3306 is default

//If you want hostname your db, you can execute query
SELECT @@hostname;

정확한 변수 이름 use을 모르는 경우 like결과에 500 개가 넘는 행이 포함될 수 있습니다.

mysql> show variables like "%port%";

default-username = root
password = you-know-it-better
url for localhost =  jdbc:mysql://localhost
default-port = 3306

MySQL Workbench를 사용하는 경우 사이드 바에있는 정보 창의 세션 탭을 살펴보십시오.

enter image description here


mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| hostname      | karola-pc |
+---------------+-----------+
1 row in set (0.00 sec)

내 경우의 예 : karola-pc내 mysql이 실행되는 상자의 호스트 이름입니다. 그리고 내 로컬 PC 호스트 이름입니다.

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)

Hope it will answer your Q.


Here are the default settings

 default-username is root
default-password is null
default-url is localhost or 127.0.0.1 for apache and     
       localhost:/phpmyadmin for mysql           // if you are using xampp
default-port = 3306

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.

참고URL : https://stackoverflow.com/questions/4093603/how-do-i-find-out-my-mysql-url-host-port-and-username

반응형