您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何配置MySQL端口避免被占用

2024/5/6 10:15:18发布35次查看
端口占用带来的问题
1.mysql 占用了其他应用的端口,导致其他应用无法运行(比如 tomcat 使用80端口,mysql 占用了该端口后 tomcat 就无法启动)。
2.mysql 端口被其他应用占用,导致 mysql 无法运行(比如某应用占用了 mysql 的 3306 端口,mysql 就无法启动了)。
3.因为许多端口都有默认使用的情况,比如 3306 是 mysql 的默认端口,如果 mysql 不使用 3306 端口,其他需要进行数据库交互的应用需要重新配置(将其引导到正确的端口)。
解决方法
mysql 的端口是可以设置的,在 my.ini(my-default.ini )中可以设置(该文件位于数据库文件夹下,高版本的 mysql 没有这样一个默认的配置文件,但创建一个这样的配置文件也可生效)。
将 port 选项前的“#”去掉,然后等式后方填上端口号,保存完毕后。再次启动数据库就会使用新端口进行数据库的交互了。
附:my.ini 文件内容:
# for advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** do not edit this file. it's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of mysql.[mysqld]# remove leading # and set to the amount of ram for the most important data# cache in mysql. start at 70% of total ram for dedicated server, else 10%.# innodb_buffer_pool_size = 128m# remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# these are commonly set, remove the # and set as required.# basedir = .....# datadir = .....# port = .....# server_id = .....# remove leading # to set options mainly useful for reporting servers.# the server defaults are faster for transactions and fast selects.# adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128m# sort_buffer_size = 2m# read_rnd_buffer_size = 2m sql_mode=no_engine_substitution,strict_trans_tables
注意事项
许多的应用都有默认端口,比如 mysql使用 3306 端口,tomcat 使用 80/8080 端口,不管是什么应用,在配置的时候最好使用默认端口避免造成不必要的麻烦。若 mysql 端口被占用,正确的解决方法是释放 3306 端口以供 mysql 使用。
以上就是如何配置mysql端口避免被占用的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product