如何找到我的 MySQL URL、主机、端口和用户名?
我需要找到我的 MySQL 用户名。当我打开 MySQL 命令行客户端时,它只询问我的密码。我不记得我的用户名了。为了与 JDBC 连接,我需要 URL、主机和端口号。我在哪里可以找到所有这些?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
如果您已经登录到命令行客户端,请尝试以下操作:
它将输出类似于以下内容的内容:
在上面的示例中,我从
localhost
以root
身份登录。要查找端口号和其他有趣的设置,请使用以下命令:
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
fromlocalhost
.To find port number and other interesting settings use this command:
如果您想知道运行 Mysql 的本地主机的端口号,您可以在 MySQL 命令行客户端上使用此查询 -
它将为您提供 MySQL 运行的端口号。
如果您想知道 Mysql 的主机名,您可以在 MySQL 命令行客户端上使用此查询 -
它将为您提供 mysql 的主机名。
如果您想知道 Mysql 的用户名,您可以在 MySQL 命令行客户端上使用此查询 -
它将为您提供 mysql 的用户名。
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:
如果您不知道确切的变量名称,请使用
like
,因为结果可能包含超过 500 行:If you don't know the exact variable name use
like
, as the result may contain more than 500 rows:如果使用 MySQL Workbench,只需查看侧边栏信息窗格中的会话选项卡即可。
If using MySQL Workbench, simply look in the Session tab in the Information pane located in the sidebar.
最简单的方法可能是使用命令 status; 在输出中,您将找到数据库、用户、主机和端口:
Easiest way is probably using command status; In the output you'll find database, user, host and port:
如果您使用 phpMyAdmin,请单击
Home
,然后单击顶部菜单上的Variables
。在页面上查找端口
设置。它设置的值是您的 MySQL 服务器正在运行的端口。If you use phpMyAdmin, click on
Home
, thenVariables
on the top menu. Look for theport
setting on the page. The value it is set to is the port your MySQL server is running on.这里的默认设置
default-username是root
default-password 为 null/空 //没有任何意义
对于 apache,default-url 是 localhost 或 127.0.0.1 和
localhost/phpmyadmin for mysql // 如果您使用的是 xampp/wamp/mamp
默认端口 = 3306
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
例如,在我的例子中: karola-pc 是运行 mysql 的主机名。这是我的本地 PC 主机名。
如果它是远程机器,那么您可以直接 ping 该主机,如果,如果您与该机器位于网络中,您应该能够 ping 该主机。
如果是
UNIX 或 Linux,您可以在终端中运行“hostname”命令
来检查主机名。如果是 Windows,您可以在
MyComputer->; 中看到相同的值右键单击-> Properties ->Computer Name
你可以看到(即系统属性)希望它能回答你的问题。
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)Hope it will answer your Q.
在本地主机或专用服务器上,转到 phpMyAdmin 内的 config.inc 文件
on local host or dedicated server, go to config.inc file inside phpMyAdmin
使用这个:
你可以使用命令检查更多变量(必须尝试)
use this:
you can check more variables by using the command (must try)