【发布时间】:2017-07-21 12:40:58
【问题描述】:
确切地说,我需要将 mysql/mariadb 10.xx 默认端口更改为端口号 15501。
通过互联网发现可以从/etc/mysql/my.cnf改成包含port=3306这一行,但是在我的cnf文件中却没有这样一行。
我的my.cnf 内容:
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
不知道为什么但是如果我尝试mysql -uroot -p -P[ANY_PORT IS ACCEPTED example 1829] 它可以使用任何端口号连接到mariadb。
netstat -a | grep mysql
tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 17787 /var/run/mysqld /mysqld.sock
mysql --version
mysql Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
我正在使用 debian 9
如果你能告诉我如何让 mysql/mariadb 只监听 15501 端口号,我将不胜感激。
【问题讨论】:
-
配置文件的第 4 到第 7 行是“MariaDB/MySQL 工具读取配置文件”的位置列表。所以看那里。其中之一将包含端口。