linux服务器mysql MariaDB端口修改加固安全防范

先来查看端口

root@:~# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 383
Server version: 5.5.68-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show global variables like ‘port’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| port | 3306 |
+—————+——-+
1 row in set (0.01 sec)

MariaDB [(none)]>

下面进入vi修改端口,改红字修改的两个地方端口再 :wq保存即可

root@:~# vi /etc/my.cnf
[client]
#password = your_password
port = 3001
socket = /tmp/mysql.sock

[mysqld]
port = 3001

重启一下MariaDB服务

systemctl restart mariadb.service

 

再查看端口,就显示了我们修改的端口了

root@:~# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.68-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show global variables like ‘port’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| port | 3001 |
+—————+——-+
1 row in set (0.00 sec)

MariaDB [(none)]>

THE END