返回列表 发帖

CentOS8_Yum安装MySQL5.7

查看操作系统的信息:
[root@centos8 ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@centos8 ~]# uname -r
4.18.0-193.el8.x86_64

[root@centos8 ~]# hostname
centos8.zhuohua.store
[root@centos8 ~]# cat /etc/hostname
centos8.zhuohua.store

[root@centos8 ~]# ifconfig
-bash: ifconfig: 未找到命令
[root@centos8 ~]#
[root@centos8 ~]# dnf -y install net-tools

[root@centos8 ~]# ifconfig ens160 |grep netmask |awk '{print $2}'
192.168.168.154


关闭SELinux:(默认是开启的,要关闭)
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config


删除原有的MySQL:
[root@centos8 ~]# dnf -y remove @mysql
[root@centos8 ~]# dnf module reset mysql
[root@centos8 ~]# dnf -y module disable mysql


创建一个仓库文件:
[root@centos8 ~]# cat /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=0


设置使用Yum安装软件包时,保存软件包到服务器本地目录:(可选)
[root@centos8 ~]# vi /etc/yum.conf
追加:
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1


效果如下:
[root@centos8 ~]# cat /etc/yum.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1



安装MySQL5.7:(要连接公网)
[root@centos8 ~]# dnf -y --enablerepo=mysql57-community install mysql-community-server


自动保存下来的软件包:
[root@centos8 ~]# cd /var/cache/yum/x86_64/8/
[root@centos8 8]# find ./ -name "*.rpm" |wc -l
46

复制指定目录下的所有rpm软件包到指定目录:
[root@centos8 ~]# mkdir -p /root/dir1
[root@centos8 ~]#
[root@centos8 ~]# find /var/cache/yum/x86_64/8/ -name "*.rpm" |xargs cp -t /root/dir1/

[root@centos8 ~]# find /root/dir1/ -name "*.rpm" |wc -l
46
[root@centos8 ~]# du -sh /root/dir1/
215M    /root/dir1/

可以在一台离线的新服务器上使用Yum一次性安装这些rpm软件包,从而实现MySQL5.7的安装:(使用本地光盘作为Yum源)
[root@centos8 ~]# yum -y install /root/dir1/*.rpm


启动MySQL5.7:
[root@centos8 ~]# systemctl start mysqld

开机自动启动MySQL5.7:
[root@centos8 ~]# systemctl enable mysqld


获取数据库管理员root@localhost的初始密码:
[root@centos8 ~]# cat /var/log/mysqld.log |grep 'A temporary password'
2021-07-15T16:21:11.026369Z 1 [Note] A temporary password is generated for root@localhost: y6dsvgQY+pj!


服务器本地登录MySQL:
mysql -uroot -p"y6dsvgQY+pj!"
图片1.png
2021-7-17 21:45



必须要修改数据库管理员root@localhost的密码:(密码要符合复杂性要求)
mysql> ALTER USER root@'localhost' IDENTIFIED BY 'P@ssw7rd';
Query OK, 0 rows affected (0.00 sec)


数据库管理员root@localhost使用新密码重新登录MySQL:
mysql -uroot -p"P@ssw7rd"
图片2.png
2021-7-17 21:46



查看默认的用户密码策略:
SHOW VARIABLES LIKE 'validate_password%';
图片3.png
2021-7-17 21:46



默认就有的库:
show databases;
图片4.png
2021-7-17 21:47



查看所有数据库用户及其主机信息:(以下是初始状态)
select user,host from mysql.user;
图片5.png
2021-7-17 21:47



查看数据库管理员root@localhost的权限:
mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)


MySQL的主配置文件:(初始状态)
[root@centos8 ~]# cat /etc/my.cnf |grep -v "^$"
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[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
#
# 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
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



自定义MySQL的主配置文件:
cat > /etc/my.cnf <<EOF
[client]
#password   = your_password
port        = 3306
socket      = /var/lib/mysql/mysql.sock

[mysqld]
port        = 3306
socket      = /var/lib/mysql/mysql.sock
datadir = /var/lib/mysql
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size = 8M
tmp_table_size = 16M
performance_schema_max_table_instances = 500

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
expire_logs_days = 10
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
innodb_buffer_pool_size = 16M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M

[mysqlhotcopy]
interactive-timeout

EOF



重启MySQL:
[root@centos8 ~]# systemctl restart mysqld


根据服务器的物理内存大小更改MySQL的主配置文件的脚本:
[root@centos8 ~]# cat change.sh
  1. #!/bin/bash

  2. MySQL_Opt()
  3. {
  4. MemTotal=`free -m | grep Mem | awk '{print  $2}'`

  5.     if [[ ${MemTotal} -gt 1024 && ${MemTotal} -lt 2048 ]]; then
  6.         sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" /etc/my.cnf
  7.         sed -i "s#^table_open_cache.*#table_open_cache = 128#" /etc/my.cnf
  8.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" /etc/my.cnf
  9.         sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" /etc/my.cnf
  10.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" /etc/my.cnf
  11.         sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" /etc/my.cnf
  12.         sed -i "s#^query_cache_size.*#query_cache_size = 16M#" /etc/my.cnf
  13.         sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" /etc/my.cnf
  14.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" /etc/my.cnf
  15.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 32M#" /etc/my.cnf
  16.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 1000#" /etc/my.cnf
  17.     elif [[ ${MemTotal} -ge 2048 && ${MemTotal} -lt 4096 ]]; then
  18.         sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /etc/my.cnf
  19.         sed -i "s#^table_open_cache.*#table_open_cache = 256#" /etc/my.cnf
  20.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /etc/my.cnf
  21.         sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /etc/my.cnf
  22.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /etc/my.cnf
  23.         sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /etc/my.cnf
  24.         sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /etc/my.cnf
  25.         sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
  26.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /etc/my.cnf
  27.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 64M#" /etc/my.cnf
  28.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 2000#" /etc/my.cnf
  29.     elif [[ ${MemTotal} -ge 4096 && ${MemTotal} -lt 8192 ]]; then
  30.         sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" /etc/my.cnf
  31.         sed -i "s#^table_open_cache.*#table_open_cache = 512#" /etc/my.cnf
  32.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" /etc/my.cnf
  33.         sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" /etc/my.cnf
  34.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" /etc/my.cnf
  35.         sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" /etc/my.cnf
  36.         sed -i "s#^query_cache_size.*#query_cache_size = 64M#" /etc/my.cnf
  37.         sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
  38.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" /etc/my.cnf
  39.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 128M#" /etc/my.cnf
  40.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 4000#" /etc/my.cnf
  41.     elif [[ ${MemTotal} -ge 8192 && ${MemTotal} -lt 16384 ]]; then
  42.         sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" /etc/my.cnf
  43.         sed -i "s#^table_open_cache.*#table_open_cache = 1024#" /etc/my.cnf
  44.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" /etc/my.cnf
  45.         sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" /etc/my.cnf
  46.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" /etc/my.cnf
  47.         sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" /etc/my.cnf
  48.         sed -i "s#^query_cache_size.*#query_cache_size = 128M#" /etc/my.cnf
  49.         sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" /etc/my.cnf
  50.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" /etc/my.cnf
  51.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 256M#" /etc/my.cnf
  52.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 6000#" /etc/my.cnf
  53.     elif [[ ${MemTotal} -ge 16384 && ${MemTotal} -lt 32768 ]]; then
  54.         sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" /etc/my.cnf
  55.         sed -i "s#^table_open_cache.*#table_open_cache = 2048#" /etc/my.cnf
  56.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" /etc/my.cnf
  57.         sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" /etc/my.cnf
  58.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" /etc/my.cnf
  59.         sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" /etc/my.cnf
  60.         sed -i "s#^query_cache_size.*#query_cache_size = 256M#" /etc/my.cnf
  61.         sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" /etc/my.cnf
  62.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" /etc/my.cnf
  63.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 512M#" /etc/my.cnf
  64.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 8000#" /etc/my.cnf
  65.     elif [[ ${MemTotal} -ge 32768 ]]; then
  66.         sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" /etc/my.cnf
  67.         sed -i "s#^table_open_cache.*#table_open_cache = 4096#" /etc/my.cnf
  68.         sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" /etc/my.cnf
  69.         sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" /etc/my.cnf
  70.         sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" /etc/my.cnf
  71.         sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" /etc/my.cnf
  72.         sed -i "s#^query_cache_size.*#query_cache_size = 512M#" /etc/my.cnf
  73.         sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" /etc/my.cnf
  74.         sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" /etc/my.cnf
  75.         sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf
  76.         sed -i "s#^performance_schema_max_table_instances.*#performance_schema_max_table_instances = 10000#" /etc/my.cnf
  77.     fi
  78. }
  79. MySQL_Opt
复制代码



运行脚本:
[root@centos8 ~]# bash change.sh


再次查看MySQL的主配置文件:
[root@centos8 ~]# cat /etc/my.cnf
[client]
#password   = your_password
port        = 3306
socket      = /var/lib/mysql/mysql.sock

[mysqld]
port        = 3306
socket      = /var/lib/mysql/mysql.sock
datadir = /var/lib/mysql
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
expire_logs_days = 10
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 768K
read_buffer_size = 768K
write_buffer_size = 2M

[mysqlhotcopy]
interactive-timeout


重启MySQL:
[root@centos8 ~]# systemctl restart mysqld


查看MySQL的最大连接数:
mysql> show variables like '%max_connection%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 500   |
+-----------------+-------+
1 row in set (0.00 sec)


查看MySQL的“最大可打开表数”:(能同时打开的表的总数量)
mysql> show variables like 'table_open%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| table_open_cache           | 128   |
| table_open_cache_instances | 16    |
+----------------------------+-------+
2 rows in set (0.00 sec)


查看MySQL的默认存储引擎:
show variables like '%storage_engine%';
图片6.png
2021-7-17 21:50



查看MySQL的默认字符集:
show variables like '%character%';
图片7.png
2021-7-17 21:51


show variables like '%collation%';
图片8.png
2021-7-17 21:51



下面,修改数据库的默认字符集为 utf8mb4_general_ci

再次查看MySQL的主配置文件:
[root@centos8 ~]# cat /etc/my.cnf
[client]
#password   = your_password
port        = 3306
socket      = /var/lib/mysql/mysql.sock

[mysqld]
port        = 3306
socket      = /var/lib/mysql/mysql.sock
datadir = /var/lib/mysql
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 16
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
expire_logs_days = 10
early-plugin-load = ""

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci


[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 768K
read_buffer_size = 768K
write_buffer_size = 2M

[mysqlhotcopy]
interactive-timeout


重启MySQL:
[root@centos8 ~]# systemctl restart mysqld


再次查看MySQL的默认字符集:
show variables like '%character%';
图片9.png
2021-7-17 21:52


show variables like '%collation%';
图片10.png
2021-7-17 21:52



新建的库的默认字符集为 utf8mb4_general_ci :
create database db1;
show create database db1;
图片11.png
2021-7-17 21:53






######

授权数据库用户zhuohua@'192.168.168.130' (密码P@ssw8rd),仅仅允许从IP地址192.168.168.130进行访问,可以对所有的库db1进行任意操作:
mysql> grant all on db1.* to zhuohua@'192.168.168.130' identified by 'P@ssw8rd';
Query OK, 0 rows affected, 1 warning (0.00 sec)


查看数据库用户zhuohua@'192.168.168.130' 的权限:
mysql> show grants for zhuohua@'192.168.168.130';
+----------------------------------------------------------------+
| Grants for zhuohua@192.168.168.130                             |
+----------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zhuohua'@'192.168.168.130'              |
| GRANT ALL PRIVILEGES ON `db1`.* TO 'zhuohua'@'192.168.168.130' |
+----------------------------------------------------------------+
2 rows in set (0.00 sec)


在防火墙firewalld插入规则:( 打开TCP 3306端口 )
[root@centos8 ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@centos8 ~]# firewall-cmd --reload
success


客户端使用数据库用户zhuohua@'192.168.168.130',从IP地址192.168.168.130远程访问MySQL5.7:
mysql -u"zhuohua" -p"P@ssw8rd" -h"192.168.168.154"
图片12.png
2021-7-17 21:54


图片13.png
2021-7-17 21:54


图片14.png
2021-7-17 21:55

备注:按前面的配置,数据库用户zhuohua@'192.168.168.130' 只能管理库db1





############

Jemalloc是内存分配器,可以提升MySQL/MariaDB的性能。


查看MySQL的版本:
[root@centos8 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.7.34, for Linux (x86_64) using  EditLine wrapper


安装Jemalloc:
[root@centos8 ~]# tar -jxf jemalloc-5.2.1.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now


[root@centos8 ~]# yum -y install bzip2

[root@centos8 ~]# tar -jxf jemalloc-5.2.1.tar.bz2
[root@centos8 ~]# cd jemalloc-5.2.1

[root@centos8 jemalloc-5.2.1]# ./configure
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/jemalloc-5.2.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details


[root@centos8 jemalloc-5.2.1]# yum -y install gcc-c++

[root@centos8 jemalloc-5.2.1]# ./configure

[root@centos8 jemalloc-5.2.1]# make
-bash: make: 未找到命令

[root@centos8 jemalloc-5.2.1]# yum -y install make

[root@centos8 jemalloc-5.2.1]# make

[root@centos8 jemalloc-5.2.1]# make install

[root@centos8 jemalloc-5.2.1]# ldconfig

[root@centos8 jemalloc-5.2.1]# ln -sf /usr/local/lib/libjemalloc* /usr/lib/



查找MySQL的环境文件:
[root@centos8 ~]# cat /usr/lib/systemd/system/mysqld.service |grep -A1 "malloc"
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql


[root@centos8 ~]# vi /etc/sysconfig/mysql
写入:
LD_PRELOAD=/usr/lib/libjemalloc.so


保存文件退出后,重启MySQL:
[root@centos8 ~]# systemctl restart mysqld



验证MySQL是否使用了Jemalloc:
[root@centos8 ~]# lsof -n |grep jemalloc
-bash: lsof: 未找到命令

[root@centos8 ~]# yum -y install lsof

[root@centos8 ~]# lsof -n |grep jemalloc
mysqld    1079                  mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1088 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1097 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1098 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1099 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1100 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1101 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1102 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1103 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1104 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1105 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1106 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1107 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1131 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1134 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1135 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1136 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1137 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1138 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1139 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1140 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1146 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1147 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1148 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1149 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1157 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2
mysqld    1079 1158 mysqld      mysql  mem       REG              253,0   6123808  201717875 /usr/local/lib/libjemalloc.so.2





相关文章:
CentOS8_Yum安装MySQL8.0
CentOS8安装LNMP+phpMyAdmin

CentOS8使用mailx(使用126邮箱的25端口)
MySQL8.0使用Jemalloc

Apache2.2+MySQL5.6+PHP5.6+phpMyAdmin+GLPI

返回列表