Mr. zero
Mr. zero

Reputation: 243

Close mysql port : 3306 and make it local

When I'm trying to show the port that's opened in my server show to me the port : 3306 and this port for mysql database

How can I close mysql port (3306) and make it just for local connections mean just local connections can connect with this port?

thnx.

Upvotes: 5

Views: 8974

Answers (2)

Resikesh M R
Resikesh M R

Reputation: 11

Debian and Ubuntu By default, MySQL on Debian and Ubuntu is configured to only use the localhost interface (IP address 127.0.0.1) for networking. This means that port 3306 is closed to external connections. To confirm that this is the configuration on your server, follow these steps:

Log in to your server using SSH. At the command prompt, use your preferred text editor to open the /etc/mysql/my.cnf file. Locate the MySQL bind-address line in the my.cnf file. It should look like the following: bind-address = 127.0.0.1 If the MySQL bind-address line is set to 0.0.0.0 (or no address at all), then connections are open on all interfaces. If you made any changes to the /etc/my.cnf file, save them and then exit the text editor. To restart the MySQL service, type the following command:

service mysql restart Port 3306 is now closed on the server.

Upvotes: 1

Zhang Buzz
Zhang Buzz

Reputation: 11068

Add the following line in your my.cnf:

[mysqld]
bind-address=127.0.0.1

Upvotes: 11

Related Questions