MySQL Variables rand_seed1 数据库 参数变量解释及正确配置使用

本站中文解释

和rand_seed2

rand_seed1和rand_seed2是MySQL随机数生成器相关参数,用于生成伪随机数。MySQL随机数生成器使用一个48位状态来存储当前的状态,其中包含24位rand_seed1和24位rand_seed2。通常情况下,如果不设定这两个参数,MySQL会根据系统时间自动生成这两个值,并保存到数据目录中的my.cnf文件或者my-new.cnf文件中。

要设置这两个参数,可以在系统的my.cnf或者my-new.cnf文件中添加这些参数:

[mysqld]
rand_seed1=500000 # 随机数种子1
rand_seed2=70000 # 随机数种子2

要生效,可以重启数据库,或者运行命令:

mysqladmin flush-privileges –p

重点:MySQL随机数生成器参数rand_seed1和rand_seed2是用于生成伪随机数,通过在my.cnf或者my-new.cnf文件中设置这两个参数来调整伪随机数的输出,即可使设置生效。

官方英文解释

rand_seed1

System Variable rand_seed1
Scope Session
Dynamic Yes
Type Integer
Default Value N/A
Minimum Value 0
Maximum Value 4294967295

The rand_seed1 and
rand_seed2 variables exist as
session variables only, and can be set but not read. The
variables—but not their values—are shown in the
output of SHOW VARIABLES.

The purpose of these variables is to support replication of
the RAND() function. For
statements that invoke RAND(),
the source passes two values to the replica, where they are
used to seed the random number generator. The replica uses
these values to set the session variables
rand_seed1 and
rand_seed2 so that
RAND() on the replica generates
the same value as on the source.


数据运维技术 » MySQL Variables rand_seed1 数据库 参数变量解释及正确配置使用