select version();" command; 2. Start the MySQL service and add a firewall policy; 3. Back up the file "mysqld.bak"; 4. Open the "/usr/sbin/mysqld" file and replace the version information in it."/> select version();" command; 2. Start the MySQL service and add a firewall policy; 3. Back up the file "mysqld.bak"; 4. Open the "/usr/sbin/mysqld" file and replace the version information in it.">
Methods to hide the mysql version: 1. Check the current mysql version through the "mysql -uroot -p> select version();" command; 2. Start the MySQL service and add a firewall policy; 3. Back up the file "mysqld .bak"; 4. Open the "/usr/sbin/mysqld" file and replace the version information in it.
The test process is recorded as follows,
Risk operations, for reference only.
mysql -uroot -p> select version();If you do not have login permission, you can also use telnet or nmap tools to perform detection scans and obtain mysql Version information:
telnet [host] [port]
nmap -T4 -sC -sV -p [port] [ip]
Name | Version | Remarks | |
---|---|---|---|
Linux operating system | CentOS 7.6 | IP: 192.168.64.147 | |
MySQL database | 5.7.22 | rpm installation |
序号 | 名称 | 版本 | 备注 |
---|---|---|---|
1 | Linux操作系统 | CentOS 7.6 | IP:192.168.64.147 |
2 | MariaDB数据库 | 5.5.68 | rpm安装 |
yum -y install mariadb-server telnet nmap net-tools
2. 开启 MySQL 服务,添加防火墙策略
systemctl start mariadb && systemctl status mariadb firewall-cmd --permanent --add-port=3306/tcp firewall-cmd --reload firewall-cmd --list-all
3. 设置密码和远程连接
mysqladmin -u root password "Aa123456."mysql -uroot -pAa123456. MariaDB [(none)]> use mysql;MariaDB [mysql]> select user,host from user;MariaDB [mysql]> update user set host='%' where user='root';MariaDB [mysql]> flush privileges;MariaDB [mysql]> select user,host from user;
4. 查看当前版本
MariaDB [mysql]> select version();MariaDB [mysql]> \q mysql -V
telnet 192.168.64.147 3306 nmap -T4 -sC -sV -p 3306 192.168.64.147
cp /usr/bin/mysql /usr/bin/mysql.bakcp /usr/libexec/mysqld /usr/libexec/mysqld.bak
2. 编辑二进制文件,替换其中的版本信息
如果只想对外部探测 MariaDB 的真实版本信息进行隐藏,只需改 /usr/libexec/mysqld 文件。
❗️❗️❗️注意:版本号不可为空或删减其他信息,否则可能导致服务无法启用!
vi /usr/bin/mysql# 搜索关键字“-MariaDB”快速定位,修改版本号,建议改为官网最新的稳定版本^@KILL %s%lu^@ERROR^@ at line %lu^@ in file: '%s'^@ERROR %d (%s)^@ERROR %d^@Linux^@5.5.68-MariaDB^@readline^@x86_64^@vi^@EDITOR^@VISUAL^@Command '%.40s' failed^@Show warnings disabled.^@Show warnings enabled.^@Usage: \! shell-command^@Charset changed^@Charset is not found^@show databases^@show tables^@%.64s.%.64s^@*** NONE ***^@Connection id: %lu^@Current database: %.128s# 参考案例:^@KILL %s%lu^@ERROR^@ at line %lu^@ in file: '%s'^@ERROR %d (%s)^@ERROR %d^@Linux^@10.7.3-MariaDB^@readline^@x86_64^@vi^@EDITOR^@VISUAL^@Command '%.40s' failed^@Show warnings disabled.^@Show warnings enabled.^@Usage: \! shell-command^@Charset changed^@Charset is not found^@show databases^@show tables^@%.64s.%.64s^@*** NONE ***^@Connection id: %lu^@Current database: %.128s
vi /usr/libexec/mysqld # 同样通过搜索关键字“-MariaDB”快速定位,修改版本号,建议改为官网最新的稳定版本^@CLOSE_CONNECTION^@unauthenticated^@unconnected^@Error in accept^@5.5.68-MariaDB^@x86_64^@Linux^@%s Ver %s for %s on %s (%s)# 参考案例:^@CLOSE_CONNECTION^@unauthenticated^@unconnected^@Error in accept^@10.7.3-MariaDB^@x86_64^@Linux^@%s Ver %s for %s on %s (%s)
3. 重启服务
systemctl restart mariadb systemctl status mariadbnetstat -nplt |grep mysqld
4. 确认版本
mysql -V mysql -h 192.168.64.147 -uroot -pAa123456. MariaDB [(none)]> select version();MariaDB [(none)]> \q
5. 其他业务相关的测试
为防止探测过程中出现错误连接次数太多导致IP被锁定,建议先提高允许的max_connection_errors数量;
或使用清楚缓存的方法,把计数清理掉
mysql -h 127.0.0.1 -uroot MariaDB [(none)]> show global variables like '%max_connect_errors%';MariaDB [(none)]> set global max_connect_errors=1000;MariaDB [(none)]> show global variables like '%max_connect_errors%';MariaDB [(none)]> flush hosts;MariaDB [(none)]> \q
复测结果
telnet 192.168.64.147 3306 nmap -T4 -sC -sV -p 3306 192.168.64.147
推荐学习:《MySQL视频教程》
The above is the detailed content of How to hide mysql version. For more information, please follow other related articles on the PHP Chinese website!