Home > Database > Mysql Tutorial > How to configure the MySQL port to avoid being occupied

How to configure the MySQL port to avoid being occupied

WBOY
Release: 2023-05-30 21:03:24
forward
1427 people have browsed it

Problems caused by port occupation

1. MySQL occupies the port of other applications, causing other applications to be unable to run (for example, Tomcat uses port 80, and MySQL occupies the port after Tomcat cannot be started).

2. The MySQL port is occupied by other applications, causing MySQL to be unable to run (for example, if an application occupies MySQL's 3306 port, MySQL cannot be started).

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

Solution

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

Remove the "#" in front of the port option, then fill in the port number after the equation, and save it. When you start the database again, the new port will be used for database interaction.

Attachment: my.ini File content:

# 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
Copy after login

Notes

Many applications have default ports, such as MySQL uses port 3306, and Tomcat uses port 80/8080. No matter what application it is, it is best to use the default port during configuration to avoid unnecessary trouble. If the MySQL port is occupied, the correct solution is to release port 3306 for use by MySQL.

The above is the detailed content of How to configure the MySQL port to avoid being occupied. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template