skip to Main Content

I installed MySQL on Kali Linux and I enabled it using
sudo systemctl enable --now mysql

I am afraid since it opens a port that it can be exploited so after finishing I run
sudo systemctl disble --now mysql

Is it required to do it?

Will it affect my PC if I don’t do it?

Why should I enable it while I am using it to create an offline program?

2

Answers


  1. You don’t have to enable the service, you only have to start or stop the service if you are concerned about leaving the port open. Enabling the service just means that it will automatically start during system boot.

    By using enable --now you are enabling AND starting the service at the same time, meaning you set the service to start at system boot and subsequently start the service in the same command.

    If you only want to manually start and stop the service just use systemctl start mysql and systemctl stop mysql.

    Alternately, leave it running and set your system up so that only you can connect. But I suspect that if you are concerned about the port being open this is not your desire.

    Login or Signup to reply.
  2. You don’t have to stop it.

    You can control who can access it in the firewall.
    If you use iptables as firewall, then:

    iptables -A INPUT -s 127.0.0.1 -p tcp --dport 3306 -j ACCEPT
    

    After that, your MySQL server can only be accessed from the localhost.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search