Step 1: Add the Security Lock
In Termius, open the file again (sudo nano /etc/my.cnf) and add the bind-address line directly under the [mysqld] header. It should look like this:
[mysqld]
bind-address=127.0.0.1
log-error=/var/lib/mysql/5-180-150-254.cprapid.com.err
performance-schema=0
innodb_buffer_pool_size=126877696
max_allowed_packet=268435456
open_files_limit=40000
innodb_file_per_table=1
plugin-load-add=auth_socket.so
unix_socket=OFF
You may need to add:
bind-address=127.0.0.1
Step 2: Save and Restart
-
Press Ctrl + O, then Enter to save.
-
Press Ctrl + X to exit.
-
Run this command to apply it:
/scripts/restartsrv_mysql
Step 3: The Test
-
Check your websites: If they load, you are 100% successful and much more secure.
-
Check the port: Run
netstat -tulnp | grep 3306. It should now show127.0.0.1:3306.
Why this is the "Safest" way
By using 127.0.0.1, you aren't just "blocking" the door with a firewall; you are essentially removing the door's handle from the outside. Even if your firewall (CSF/iptables) is accidentally turned off or "expires," the database will still refuse to listen to anyone from the internet.
Give that a try in Termius—did the restart go through smoothly, or did you get an error message?