Coder
Coder

Reputation: 7

how to find mariadb port number in navicate

I have a mariadb installed on my system, and I want to connect it with spring boot using jpa, so I've forgot my port number

Can someone tell me how I can find it in navicate

Upvotes: -1

Views: 425

Answers (1)

FanoFN
FanoFN

Reputation: 7124

  1. If you haven't connected to the database using Navicat yet and you don't already have the port, then there's no way you can find out the port from Navicat.

  2. If you are currently connected to the database through Navicat, simply click the connection tab
    navicat connection tab
    and you'll be shown with this dialog
    navicat connection dialog
    Then you can see the port. Even if you're not using Navicat, most tools that I know of will always need a specific port for the database connection so if you ever save the connection info on the tools, and the port is unchanged, then you can find it there.

  3. If you're using Windows, you can try this method:
    a. Make sure the database service is running then open task manager > go to "details" tab and find process name "mysqld.exe" :
    task manager
    if you have multiple process, note down all of the "PID" numbers.
    b. Open Command Prompt (as administrator if required) then type the following
    netstat -aon | findstr "PID" then press "Enter"; for example, the "PID" is 2668 so like this:
    enter image description here
    You might get result of two or more rows depending on the connection made to your database but the port will all be the same. In that example, the port is 4238, that is beside the word TCP:

Protocol Local Address (local IP:port) Foreign Address State PID
TCP 0.0.0.0:4238 0.0.0.0:0 LISTENING 2668
  1. Another method you can try is simply checking the "my.ini/my.cnf" file. If you don't know where to locate that, in Windows, open "run" dialog and type "services.msc" then click "OK".
    services
    Find MariaDB/MySQL service name (or whatever custom service name you gave to it), right click it then select "Properties":
    mysql properties
    Once the "Properties" dialog open, highlight and drag your mouse to the right (end) at the text below the "Path to executable" area to locate where your "my.ini" file is.
    mysql prop dialog
    You can just highlight the path where the "my.ini" file, paste in "Run" then click "OK" and the file will be opened:
    enter image description here
    You can find the port under [mysqld] and [client] section. Both should have the same port but depending on your MariaDB version, the information might not be the same as this screenshot:
    enter image description here

Additional:
IF somehow you are connected to the database through a tool (like Navicat) and able to run query but (strangely) unable to check the connection properties, then you can execute this query to get the database port number: SHOW VARIABLES LIKE '%port%';

Upvotes: 0

Related Questions