Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the MySQL port to avoid being occupied

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to configure MySQL port to avoid being occupied". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to configure MySQL port to avoid being occupied" can help you solve the problem.

Problems caused by port occupancy

1.MySQL occupies the port of other applications, making it impossible for other applications to run (for example, Tomcat uses port 80, and Tomcat cannot start after MySQL occupies this port).

The 2.MySQL port is occupied by other applications, so that MySQL cannot be run (for example, if an application occupies port 3306 of MySQL, MySQL cannot be started).

3. Because many ports are used by default, for example, 3306 is the default port for MySQL, if MySQL does not use port 3306, other applications that require database interaction need to be reconfigured (boot to the correct port).

Solution method

The port of MySQL can be set, which can be set in my.ini (my-default.ini) (this file is located in the database folder, the higher version of MySQL does not have such a default configuration file, but creating such a configuration file can also take effect).

Remove the "#" before the port option, then fill in the port number after the equation, and save it. Start the database again and the new port will be used for database interaction.

Attached: contents of my.ini file:

# 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

Matters needing attention

Many applications have a default port, such as port 3306 for MySQL and port 80max for Tomcat. No matter what application it is, it is best to use the default port when configuring it to avoid unnecessary trouble. If the MySQL port is occupied, the correct solution is to clear port 3306 for MySQL use.

This is the end of the content on "how to configure the MySQL port to avoid being occupied". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report