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 命令行客户端上使用这个查询——
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 命令行客户端上使用这个查询——
select user();
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
//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;
mysql> status;
--------------
mysql Ver 8.0.13 for Win64 on x86_64 (MySQL Community Server - GPL)
Connection id: 43
Current database: mysql
Current user: user@localhost
SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256
Using delimiter: ;
Server version: 8.0.13 MySQL Community Server - GPL
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: cp852
Conn. characterset: cp852
TCP port: 3306
Uptime: 3 hours 32 min 40 sec
Threads: 3 Questions: 197 Slow queries: 0 Opens: 214 Flush tables: 2 Open tables: 190 Queries per second avg: 0.015
--------------