侧边栏壁纸
  • 累计撰写 27 篇文章
  • 累计创建 9 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

解决mysql5.7 安装unknown variable 'mysqlx_port=0.0' 问题

仓鼠
2024-06-11 / 0 评论 / 1 点赞 / 132 阅读 / 24412 字 / 正在检测是否收录...

解决mysql5.7 安装unknown variable 'mysqlx_port=0.0' 问题

在腾讯云服务器上,上装好几次都出现了 initializing database 异常问题

一下完整的log日志

eginning configuration step: Writing configuration file

Saving my.ini configuration file...
Saved my.ini configuration file.
Ended configuration step: Writing configuration file

Beginning configuration step: Updating Windows Firewall rules

Adding a Windows Firewall rule for MySQL57 on port 3306.
Attempting to add a Windows Firewall rule with command: netsh.exe advfirewall firewall add rule name="Port 3306" protocol=TCP localport=3306 dir=in action=allow
Ok.


Successfully added the Windows Firewall rule.
Ended configuration step: Updating Windows Firewall rules

Beginning configuration step: Adjusting Windows service

Attempting to grant the required filesystem permissions to the 'NT AUTHORITY\NetworkService' account.
Granted permissions to the data directory.
Adding new service
New service added
Ended configuration step: Adjusting Windows service

Beginning configuration step: Initializing database (may take a long time)

Deleting the data directory from a previous (failed) configuration...
Attempting to run MySQL Server with --initialize-insecure option...
Starting process for MySQL Server 5.7.43...
Starting process with command: C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console --initialize-insecure=on --lower-case-table-names=1...
TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
InnoDB: New log files created, LSN=45790
InnoDB: Creating foreign key constraint system tables.
unknown variable 'mysqlx_port=0.0'
Aborting
Process for mysqld, with ID 912, was run successfully and exited with code 1.
Failed to start process for MySQL Server 5.7.43.
Database initialization failed.
Ended configuration step: Initializing database (may take a long time)

从报错内容上来看,报错内容出现在、

unknown variable 'mysqlx_port=0.0'

我也是从官网下载的mysql,但是发现正常流程走下来还是不行,重装好几次系统。

问了gpt

这表明在 my.ini 配置文件中存在一个未识别的变量 mysqlx_port。MySQL 5.7 版本不支持这个变量,所以导致了初始化失败。解决这个问题的方法如下:

  1. 编辑 my.ini 配置文件: 找到 my.ini 配置文件,通常位于 C:\ProgramData\MySQL\MySQL Server 5.7\ 目录下。

  2. 删除或注释掉 mysqlx_port 配置项: 打开 my.ini 文件,找到包含 mysqlx_port 的配置行,删除该行或在行首添加一个 # 进行注释。例如:

但是情况是在安装时出现的问题。

问题解决方案

那么找到问题出现的情况,则解决初始化时mysql的my.ini模板。路径在

C:\ProgramData\MySQL\MySQL Installer for Windows\Manifest\Templates

我从其他成功安装mysql的电脑上发现了其中的问题,同样是my-template-5.7.ini 文件。

最近安装的末尾就存在mysqlx_port= 的配置。所以我直接替换过去,重新安装便解决。

附正常的:my-template-5.7.ini 内容

## MySQL Server Instance Configuration File Template
## ----------------------------------------------------------------------
## Version 1.0.10
##
## <-- Indicates Template comment.  These lines will not be in the output
##
## Replaceable things must be like:
## 
## # [VARIABLE_NAME]="Formula"
## parameter=default value
##
##  For example:
##
##  # [PORT]="port"
##  port=3306
##
## Note - In the example, the formula consists of a variable named 'port' which must be defined before processing.
##
## In addition to the standard max operators (+, -, /, *), the "formula" field supports the following functions:
##
##  rnd(x, y) = Round x to the nearest y
##  max(x, y) = Max value from x, y
##  min(x, y) = Min value from x, y
##
## and named variables.
##
##  For example:
##
##  # [MAX_CONNECTIONS]="max_connections:rnd(max(100,max_connections),1000)"
##  max_connections=
##
## ( Note - Uninitialized variables have a value of 0. )
##
## Special directives:
## - [DEFAULT]: Allows to specify a default value for a variable.
## This directive must come as the first directive. If the Server
## type is set to 4 (Manual) it will cause other directives to be ignored,
## If the Server type is other than 4, this directive will be ignored.
## - [STATE_CHANGE]: Allows for a function to be executed at that 
## point during template processing. 
##
##  For example:
## # [STATE_CHANGE]="new_variable : 1"
##
## The following variables must be defined before the formulas are evaluated (otherwise, you get many values set to 0):
##
## memory             - Server Type
##                      Dedicated Server (90% of System Memory), Server (50% of System Memory), All others( rnd(max( 1/12 System Memory, 40*1024*1024), 1024))
## myiasm_percentage  - Table Type
##                      If main InnoDB, set to 5.  Allow userdef.
## active_connections - # Connections.
##                      DSS = 20, OLTP = 500, else user_defined.
## cpus               - Number of CPUS on the machine.
## 
# Other default tuning values
##
## innodb_buffer_pool_size_percentage=2/10
# [STATE_CHANGE]="over_commit_factor:10"
##
##
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows, when MySQL has been installed using MySQL Installer you
# should keep this file in the ProgramData directory of your server
# (e.g. C:\ProgramData\MySQL\MySQL Server X.Y). To make sure the server
# reads the config file, use the startup option "--defaults-file".
#
# To run the server from the command line, execute this in a 
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a 
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guidelines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
# For advice on how to change settings please see
# https://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
#
#
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

# [CLIENT_PIPE]=""
# pipe=

# [CLIENT_SOCKET]="socket"
# socket=

# [CLIENT_PORT]="port"
port=3306

[mysql]
no-beep

# [CLIENT_DEFAULT_CHARACTER_SET]=""
# default-character-set=


# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
# [SERVER_TYPE]="server_type"
# server_type=
[mysqld]

# The next three options are mutually exclusive to SERVER_PORT below.
# [SERVER_SKIP]=""
# skip-networking=
# [SERVER_PIPE]=""
# enable-named-pipe=
# [SHARED_MEMORY]=""
# shared-memory=

# [SHARED_MEMORY_BASE_NAME]="shared_memory_base_name"
# shared-memory-base-name=

# The Pipe the MySQL Server will use
# [SERVER_SOCKET]="socket"
# socket=

# [VERSION_MIN]="5.7.25"
# The access control granted to clients on the named pipe created by the MySQL Server.
# [NAMED_PIPE_FULL_ACCESS_GROUP]="named_pipe_full_access_group"
# named-pipe-full-access-group=

# The TCP/IP Port the MySQL Server will listen on
# [SERVER_PORT]="port"
port=3306

# Path to installation directory. All paths are usually resolved relative to this.
# [BASE_DIR]="basedir"
# basedir=

# Path to the database root
# [DATA_DIR]="datadir"
datadir=

# The default character set that will be used when a new schema or table is
# created and no character set is defined
# [SERVER_DEFAULT_CHARACTER_SET]=""
# character-set-server=

# The default storage engine that will be used when create new tables when
# [DEFAULT_STORAGE_ENGINE]="default_storage_engine"
default-storage-engine=

# The current server SQL mode, which can be set dynamically.
# Modes affect the SQL syntax MySQL supports and the data validation checks it performs. This 
# makes it easier to use MySQL in different environments and to use MySQL together with other 
# database servers.
# [SQL_MODE]=""
sql-mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# General and Slow logging.
# [LOG_OUT]="log_out"
log-output=

# [GEN_QUERY]="gen_query"
general-log=

# [GEN_QUERY_FILE]="gen_query_file"
general_log_file=

# [SLOW_QUERY]="slow_query"
slow-query-log=

# [SLOW_QUERY_FILE]="slow_query_file"
slow_query_log_file=

# [LONG_QUERY]="long_query_time"
long_query_time=

# Error Logging.
# [LOG_ERR]="log_error"
log-error=

# ***** Group Replication Related *****
# Specifies the base name to use for binary log files. With binary logging
# enabled, the server logs all statements that change data to the binary
# log, which is used for backup and replication.
# [LOG_BIN]="log_bin"
log-bin=

# ***** Group Replication Related *****
# Specifies the server ID. For servers that are used in a replication topology,
# you must specify a unique server ID for each replication server, in the
# range from 1 to 2^32 − 1. "Unique" means that each ID must be different
# from every other ID in use by any other replication source or replica.
# [SERVER_ID]="server_id"
server-id=

# ***** Group Replication Related *****
# Indicates how table and database names are stored on disk and used in MySQL.
# Value 0 = Table and database names are stored on disk using the lettercase specified in the CREATE 
#           TABLE or CREATE DATABASE statement. Name comparisons are case-sensitive. You should not 
#           set this variable to 0 if you are running MySQL on a system that has case-insensitive file 
#           names (such as Windows or macOS). If you force this variable to 0 with 
#           --lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames 
#           using different lettercases, index corruption may result.
# Value 1 = Table names are stored in lowercase on disk and name comparisons are not case-sensitive. 
#           MySQL converts all table names to lowercase on storage and lookup. This behavior also applies 
#           to database names and table aliases.
# Value 2 = Table and database names are stored on disk using the lettercase specified in the CREATE TABLE 
#           or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons 
#           are not case-sensitive. This works only on file systems that are not case-sensitive! InnoDB 
#           table names and view names are stored in lowercase, as for lower_case_table_names=1.
# [LOWER_CASE_TABLE_NAMES]="lower_case_table_names"
lower_case_table_names=

# This variable is used to limit the effect of data import and export operations, such as 
# those performed by the LOAD DATA and SELECT ... INTO OUTFILE statements and the 
# LOAD_FILE() function. These operations are permitted only to users who have the FILE privilege.
# [SECURE_FILE_PRIV]="secure_file_priv"
# secure-file-priv=

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
# [DEFAULT]="max_connections:151"
# [STATE_CHANGE]="max_connections:rnd(min(active_connections*15/10+10,memory/512K),1000)"
# [MAX_CONNECTIONS]="max_connections:rnd(max(151,max_connections),1000)"
max_connections=

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
# [STATE_CHANGE]="available_memory:max(0,memory-(max_connections*256K))"
# [STATE_CHANGE]="buffers_memory:available_memory*7/10"
# [STATE_CHANGE]="thread_buffers_memory:available_memory*3/10"
# [STATE_CHANGE]="memory_per_thread:thread_buffers_memory*over_commit_factor/max_connections"
# [TABLE_OPEN_CACHE]="table_open_cache:2000"
table_open_cache=

# Defines the maximum size of internal in-memory temporary tables created 
# by the MEMORY storage engine and, as of MySQL 8.0.28, the TempTable storage 
# engine. If an internal in-memory temporary table exceeds this size, it is 
# automatically converted to an on-disk internal temporary table.
# [DEFAULT]="tmp_table_size:16M","USE_BYTES"
# [STATE_CHANGE]="buffers_memory:buffers_memory-table_open_cache*8K"
# [STATE_CHANGE]="big_thread_buffers:memory_per_thread*over_commit_factor"
# [STATE_CHANGE]="tmp_table_size:max(16M,big_thread_buffers)"
# [TMP_TABLE_SIZE]="tmp_table_size:min(tmp_table_size,memory*1/10)","USE_BYTES"
tmp_table_size=

#*** MyISAM Specific options
# The maximum size of the temporary file that MySQL is permitted to use while re-creating a 
# MyISAM index (during REPAIR TABLE, ALTER TABLE, or LOAD DATA). If the file size would be 
# larger than this value, the index is created using the key cache instead, which is slower. 
# The value is given in bytes.
# [MYISAM_MAX_SORT_FILE_SIZE]="myisam_max_sort_file_size:2146435072"
myisam_max_sort_file_size=

# The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE 
# or when creating indexes with CREATE INDEX or ALTER TABLE.
# [DEFAULT]="myisam_sort_buffer_size:8M","USE_BYTES"
# [STATE_CHANGE]="myisam_sort_buffer_size:max(8M,big_thread_buffers)"
# [MYISAM_SORT_BUFFER_SIZE]="myisam_sort_buffer_size:min(myisam_sort_buffer_size,memory*2/10)","USE_BYTES"
myisam_sort_buffer_size=

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
# [DEFAULT]="key_buffer_size:8M","USE_BYTES"
# [STATE_CHANGE]="myisam_buffers:buffers_memory*(myisam_percentage/100)"
# [KEY_BUFFER_SIZE]="key_buffer_size:max(8M,myisam_buffers/2)","USE_BYTES"
key_buffer_size=

# Each thread that does a sequential scan for a MyISAM table allocates a buffer 
# of this size (in bytes) for each table it scans. If you do many sequential 
# scans, you might want to increase this value, which defaults to 131072. The 
# value of this variable should be a multiple of 4KB. If it is set to a value 
# that is not a multiple of 4KB, its value is rounded down to the nearest multiple 
# of 4KB.
# [DEFAULT]="read_buffer_size:128K","USE_BYTES"
# [STATE_CHANGE]="read_buffer_size:min(128K,memory_per_thread*2/100)"
# [READ_BUFFER_SIZE]="read_buffer_size:min(read_buffer_size,memory/100)","USE_BYTES"
read_buffer_size=

# This variable is used for reads from MyISAM tables, and, for any storage engine, 
# for Multi-Range Read optimization.
# [DEFAULT]="read_rnd_buffer_size:256K","USE_BYTES"
# [STATE_CHANGE]="read_rnd_buffer_size:min(256K,memory_per_thread*4/10)"
# [READ_RND_BUFFER_SIZE]="read_rnd_buffer_size:min(read_rnd_buffer_size,memory*4/100)","USE_BYTES"
read_rnd_buffer_size=

#*** INNODB Specific options ***
# [INNODB_HOME]=""
# innodb_data_home_dir=

# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
# [SKIP_INNODB]
# skip-innodb

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size in bytes of the buffer that InnoDB uses to write to the log files on 
# disk. The default value changed from 8MB to 16MB with the introduction of 32KB 
# and 64KB innodb_page_size values. A large log buffer enables large transactions 
# to run without the need to write the log to disk before the transactions commit. 
# Thus, if you have transactions that update, insert, or delete many rows, making 
# the log buffer larger saves disk I/O.
# [INNODB_LOG_BUFFER_SIZE]="innodb_log_buffer_size:16M","USE_BYTES"
innodb_log_buffer_size=

# The size in bytes of the buffer pool, the memory area where InnoDB caches table 
# and index data. The default value is 134217728 bytes (128MB). The maximum value 
# depends on the CPU architecture; the maximum is 4294967295 (232-1) on 32-bit systems 
# and 18446744073709551615 (264-1) on 64-bit systems. On 32-bit systems, the CPU 
# architecture and operating system may impose a lower practical maximum size than the 
# stated maximum. When the size of the buffer pool is greater than 1GB, setting 
# innodb_buffer_pool_instances to a value greater than 1 can improve the scalability on 
# a busy server.
# [INNODB_BUFFER_POOL_SIZE]="innodb_buffer_pool_size:128M","USE_BYTES"
innodb_buffer_pool_size=

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
# [INNODB_LOG_FILE_SIZE]="innodb_log_file_size:48M","USE_BYTES"
innodb_log_file_size=

# Defines the maximum number of threads permitted inside of InnoDB. A value 
# of 0 (the default) is interpreted as infinite concurrency (no limit). This 
# variable is intended for performance tuning on high concurrency systems.
# InnoDB tries to keep the number of threads inside InnoDB less than or equal to 
# the innodb_thread_concurrency limit. Once the limit is reached, additional threads 
# are placed into a "First In, First Out" (FIFO) queue for waiting threads. Threads 
# waiting for locks are not counted in the number of concurrently executing threads.
# [DEFAULT]="innodb_thread_concurrency:0"
# [INNODB_THREAD_CONCURRENCY]="innodb_thread_concurrency:max(8,2*cpus+1)"
innodb_thread_concurrency=

# The increment size (in MB) for extending the size of an auto-extend InnoDB system tablespace file when it becomes full.
# [INNODB_AUTOEXTEND_INCREMENT]="innodb_autoextend_increment:64"
innodb_autoextend_increment=

# The number of regions that the InnoDB buffer pool is divided into.
# For systems with buffer pools in the multi-gigabyte range, dividing the buffer pool into separate instances can improve concurrency,
# by reducing contention as different threads read and write to cached pages.
# [STATE_CHANGE]="innodb_buffer_pool_instances:rnd(innodb_buffer_pool_size/134217728,1)"
# [INNODB_BUFFER_POOL_INSTANCES]="innodb_buffer_pool_instances:max((innodb_buffer_pool_instances*bitedness), 8)"
innodb_buffer_pool_instances=

# Determines the number of threads that can enter InnoDB concurrently.
# [INNODB_CONCURRENCY_TICKETS]="innodb_concurrency_tickets:5000"
innodb_concurrency_tickets=

# Specifies how long in milliseconds (ms) a block inserted into the old sublist must stay there after its first access before
# it can be moved to the new sublist.
# [INNODB_OLD_BLOCKS_TIME]="innodb_old_blocks_time:1000"
innodb_old_blocks_time=

# When this variable is enabled, InnoDB updates statistics during metadata statements.
# [INNODB_STATS_ON_METADATA]="innodb_stats_on_metadata:0"
innodb_stats_on_metadata=

# When innodb_file_per_table is enabled (the default in 5.6.6 and higher), InnoDB stores the data and indexes for each newly created table
# in a separate .ibd file, rather than in the system tablespace.
# [INNODB_FILE_PER_TABLE]="innodb_file_per_table:1"
innodb_file_per_table=

# Use the following list of values: 0 for crc32, 1 for strict_crc32, 2 for innodb, 3 for strict_innodb, 4 for none, 5 for strict_none.
# [INNODB_CHECKSUM_ALGORITHM]="innodb_checksum_algorithm:0"
innodb_checksum_algorithm=

# If this is set to a nonzero value, all tables are closed every flush_time seconds to free up resources and
# synchronize unflushed data to disk.
# This option is best used only on systems with minimal resources.
# [FLUSH_TIME]="flush_time:0"
flush_time=

# The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use
# indexes and thus perform full table scans.
# [JOIN_BUFFER_SIZE]="join_buffer_size:256K","USE_BYTES"
join_buffer_size=

# The maximum size of one packet or any generated or intermediate string, or any parameter sent by the
# mysql_stmt_send_long_data() C API function.
# [MAX_ALLOWED_PACKET]="max_allowed_packet:4M","USE_BYTES"
max_allowed_packet=

# If more than this many successive connection requests from a host are interrupted without a successful connection,
# the server blocks that host from performing further connections.
# [MAX_CONNECT_ERRORS]="max_connect_errors:100"
max_connect_errors=

# Changes the number of file descriptors available to mysqld.
# You should try increasing the value of this option if mysqld gives you the error "Too many open files".
# [OPEN_FILES_LIMIT]="open_files_limit:10+max_connections+table_open_cache*2"
open_files_limit=

# If you see many sort_merge_passes per second in SHOW GLOBAL STATUS output, you can consider increasing the
# sort_buffer_size value to speed up ORDER BY or GROUP BY operations that cannot be improved with query optimization
# or improved indexing.
# [SORT_BUFFER_SIZE]="sort_buffer_size:256K","USE_BYTES"
sort_buffer_size=

# Specify the maximum size of a row-based binary log event, in bytes.
# Rows are grouped into events smaller than this size if possible. The value should be a multiple of 256.
# [BINLOG_ROW_EVENT_MAX_SIZE]="binlog_row_event_max_size:8192","USE_BYTES"
binlog_row_event_max_size=

# If the value of this variable is greater than 0, a replica synchronizes its master.info file to disk.
# (using fdatasync()) after every sync_master_info events.
# [SYNC_MASTER_INFO]="sync_master_info:10000"
sync_master_info=

# If the value of this variable is greater than 0, the MySQL server synchronizes its relay log to disk.
# (using fdatasync()) after every sync_relay_log writes to the relay log.
# [SYNC_RELAY_LOG]="sync_relay_log:10000"
sync_relay_log=

# If the value of this variable is greater than 0, a replica synchronizes its relay-log.info file to disk.
# (using fdatasync()) after every sync_relay_log_info transactions.
# [SYNC_RELAY_LOG_INFO]="sync_relay_log_info:10000"
sync_relay_log_info=

# Load mysql plugins at start."plugin_x ; plugin_y".
# [PLUGIN_LOAD]="plugin_load"
plugin_load=

# The TCP/IP Port the MySQL Server X Protocol will listen on.
# [LOOSE_MYSQLX_PORT]="loose_mysqlx_port"
loose_mysqlx_port=

1

评论区